Problem setting foreground brush on TextBlock RRS feed

  • General discussion

  • I have a usercontrol that is a Grid with a collection of TextBlock elements that are used as the contents for a ScrollViewer. The TextBlocks are all defined the same (code below) except for their unique text. All the TextBlocks have an event handler for MouseLeftButtonDown (they all use the same handler) to set the foreground brush to the selected color and to change to overall behavior of the application. There are 25 TextBlocks in all in the usercontrol grid. The problem I'm having is that the last two TextBlock items are not showing as visible when running the application, either on a phone or in the emulator. If I remove the OpacityMask on the problem controls then they will show visible but then they do not respond to having their Foreground brush set programatically. At the initialization of the program I set the Foreground brush for all the TextBlocks to a default value (I iterate through the controls of the containing Grid). The odd thing is that the invisible TextBlock controls still respond normally to MouseLeftButtonDown.

    Any ideas or suggestions would be greatly appreciated.

           <TextBlock x:Name="xxxxx" Foreground="#FFFFFFFF"  TextWrapping="Wrap" Text="xxx" Width="61" FontSize="29.333" TextAlignment="Center" OpacityMask="Black" Tag="xxxx"  HorizontalAlignment="Left" Margin="28,0,0,0" MouseLeftButtonDown="tb_MouseLeftButtonUp">

    Sunday, May 6, 2012 11:58 PM