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. WPF
  4. FlowDocument - different coloured text in a word

FlowDocument - different coloured text in a word

Scheduled Pinned Locked Moved WPF
question
8 Posts 3 Posters 0 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.
  • R Offline
    R Offline
    RugbyLeague
    wrote on last edited by
    #1

    If I want to display the word "hello" in a flowdocument I would write:

    hello

    How do I get each letter of the word "hello" to be a different colour?

    P 1 Reply Last reply
    0
    • R RugbyLeague

      If I want to display the word "hello" in a flowdocument I would write:

      hello

      How do I get each letter of the word "hello" to be a different colour?

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      Each letter will be in its own Run and you would style them individually.

      *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

      "Mind bleach! Send me mind bleach!" - Nagy Vilmos

      CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

      R 2 Replies Last reply
      0
      • P Pete OHanlon

        Each letter will be in its own Run and you would style them individually.

        *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

        "Mind bleach! Send me mind bleach!" - Nagy Vilmos

        CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

        R Offline
        R Offline
        RugbyLeague
        wrote on last edited by
        #3

        Thank's for your reply. Run adds a space so I get "H e l l o"

        M 1 Reply Last reply
        0
        • R RugbyLeague

          Thank's for your reply. Run adds a space so I get "H e l l o"

          M Offline
          M Offline
          Matt T Heffron
          wrote on last edited by
          #4

          Use a Span tag for each character: <Span Foreground="Red">H</Span><Span Foreground="Orange">e</Span><Span Foreground="Yellow">l</Span><Span Foreground="Green">l</Span><Span Foreground="Blue">o</Span>

          R 1 Reply Last reply
          0
          • M Matt T Heffron

            Use a Span tag for each character: <Span Foreground="Red">H</Span><Span Foreground="Orange">e</Span><Span Foreground="Yellow">l</Span><Span Foreground="Green">l</Span><Span Foreground="Blue">o</Span>

            R Offline
            R Offline
            RugbyLeague
            wrote on last edited by
            #5

            Span adds leading spaces too

            M 1 Reply Last reply
            0
            • R RugbyLeague

              Span adds leading spaces too

              M Offline
              M Offline
              Matt T Heffron
              wrote on last edited by
              #6

              I tested it! :) ... (in WPF, not Silverlight) Of course, there can be no spaces between the Span tags (end of one Span and beginning of the next). Just as I showed in posting above...

              R 1 Reply Last reply
              0
              • M Matt T Heffron

                I tested it! :) ... (in WPF, not Silverlight) Of course, there can be no spaces between the Span tags (end of one Span and beginning of the next). Just as I showed in posting above...

                R Offline
                R Offline
                RugbyLeague
                wrote on last edited by
                #7

                Ah - I just found that out too - it's the same with Run Thanks for your help :-D

                1 Reply Last reply
                0
                • P Pete OHanlon

                  Each letter will be in its own Run and you would style them individually.

                  *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

                  "Mind bleach! Send me mind bleach!" - Nagy Vilmos

                  CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

                  R Offline
                  R Offline
                  RugbyLeague
                  wrote on last edited by
                  #8

                  You were right - but all the Run elements have to be on the same line. Thanks for your help<

                  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