In XAML I implemented a GridView binded with data. In the GridViewItem I put a StackPanel with TextBlock etc. and I would like to manipulate the look of the TextBlock (by its attributes) when that specific GridViewItem is clicked. I can’t reach the TextBlock from the C# code so I can’t reach its attributes either. What am I missing here? Thanks in advance. Here is some XAML code:
<GridView x:Name="gw" ...>
<GridView.ItemTemplate>
<DataTemplate>
<GridViewItem x:Name="gwi">
<StackPanel>
<TextBlock x:Name="tb">
<Run Text="{Binding SomeData}"/>
</TextBlock>
</StackPanel>
</GridViewItem>
</DataTemplate>
</GridView.ItemTemplate>
</GridView>
In this example, how can I use the “tb” named TextBlock and its attributes? I can use only “gw”.
I don’t think it’s possible to access each individual element in the data template. You can however, modify the TextBlock’s attributes using data binding. You can use a binding converter to convert the values as may be required.
Refer to http://msdn.microsoft.com/en-us/library/system.windows.data.binding.converter.aspx