如何从我的 C# 代码访问存储在 GridView 项目的 DataTemplate 中的 Canvas 控件?
<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>
我正在从 C# 代码填充 GridViewData 项,使用来自远程加载的 XML 的数据设置 GridViewData.ItemsSource。
然后我需要分别修改每个元素的画布(通过添加子元素)。
但我不明白我该怎么做。
有人可以帮我吗?先感谢您!