Search code examples
c#propertiestextblock

inaccessible properties of objects


I am using C#, Silverlight.

Some properties of some objects don't seem to be available to me. For example, the TextBlock class is supposed to have a Background property, but my Visual Studio doesn't seem to realize it.

My example code:

// myTextBlock is a TextBlock, myColor is a SolidColorBrush.Color
// these objects were both initiated elsewhere
myTextBlock.Foreground= myColor;

The Foreground property works just fine.

But if I try the Background property:

myTextBlock.Background = myColor;

This doesn't work as Visual Studio doesn't recognize that TextBlocks have a Background property.

Online documentation of the TextBlock class: http://msdn.microsoft.com/en-us/library/system.windows.controls.textblock.aspx

Any idea what is going on?


Solution

  • TextBlock.Background isn't available in Silverlight.

    There's framework version switch at the top of MSDN pages. Turn it into 'Silverlight' position, an you'll see actual properties list.