How can I access a Canvas control, stored in DataTemplate of GridView items from my C# code?
<DataTemplate x:Key="250x250ItemTemplate">
<Grid HorizontalAlignment="Left" Width="250" Height="250">
<Border Background="{StaticResource ListViewItemPlaceholderBackgroundThemeBrush}">
<Canvas x:Name="Canv"/> <------ I WANT ACCESS THIS CANVAS FROM C# CODE
</Border>
</Grid>
</DataTemplate>
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
<GridView x:Name="GridViewData" ItemTemplate="{StaticResource 250x250ItemTemplate}"/>
</Grid>
I’m filling GridViewData items from C# code, setting GridViewData.ItemsSource with data from remotely loaded XML.
Then I need to modify Canvas (by adding children to it) of each element separately.
But I don’t understand how can I do that.
Can anyone help me with it?
Thank you in advance!
Everyone who interested in answering this question!
I’ve found a solution here: http://www.wiredprairie.us/blog/index.php/archives/1730
It’s horrible that I don’t understand why we need to do so much magic here, but it works.
and
If anyone can explain for me what we’re doing in this bunch of code – please do this, ’cause my brain is exploding right now 🙂
Thank you all!