Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WCF and WF
  4. Binding TextBlock to styled text in code?

Binding TextBlock to styled text in code?

Scheduled Pinned Locked Moved WCF and WF
wpfcsharpwcfquestion
3 Posts 2 Posters 3 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    artwallacex
    wrote on last edited by
    #1

    I want to duplicate this XAML code but I want to dynamically create the text in C#.

    <TextBlock>
    <Run Background="Blue">Text1</Run>
    <Run Background="Red">Text2</Run>
    </TextBlock>

    How are the Runs added to the TextBox?

    I 1 Reply Last reply
    0
    • A artwallacex

      I want to duplicate this XAML code but I want to dynamically create the text in C#.

      <TextBlock>
      <Run Background="Blue">Text1</Run>
      <Run Background="Red">Text2</Run>
      </TextBlock>

      How are the Runs added to the TextBox?

      I Offline
      I Offline
      Insincere Dave
      wrote on last edited by
      #2

      Add the Run objects to the TextBlock.Inlines collection.

      A 1 Reply Last reply
      0
      • I Insincere Dave

        Add the Run objects to the TextBlock.Inlines collection.

        A Offline
        A Offline
        artwallacex
        wrote on last edited by
        #3

        How do I bind to Inlines? According to the docs it seems to be read-only. Do I need to switch to a Label or Textbox?

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups