Question

I try to describe my problem more deeply. I have listbox full of item taken from ObservableCollection<show>, in some cases I need to show DIAMETER SIGN with properly value at the listbox item area.

For example

enter image description here

If I would like to have it in every box I would put it hardcoded or make binding with hardcoded value, but only part of items have the value which should be showed with diameter sign. Here is the fragment of code from the show class, which should return the properly sign

public string Thickness 
        {
            get 
            {
                if (thickness == 1)
                {
                    return "&#x2300;28cm";
                }
                else if (thickness == 2)
                {
                    return "&#x2300;50cm";
                }
                else 
                { 
                    return ""; 
                }
            }
        }

and fragment of my code from xaml

  <TextBlock  
         Foreground="#69AB5C"
         FontSize="15" 
         VerticalAlignment="Bottom"
         Text="{Binding Thickness}">
  </TextBlock>

and here the question how should I pass from my observable collection the unicode character to xaml

Was it helpful?

Solution

Hallelujah!

Here is the solution pal in your property change it from

return "&#x2300;50cm";

to

return ((char)0x2300).ToString();

and for 50cm part you can always use mulitbinding or use char array and bind it to that. :-)

OTHER TIPS

You're using XML escape characters. You need to use C# character literals:

return "\x230028cm";
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top