我正在尝试禁用 TextBlock 的可见性。我可以在以下示例中引用 TextBlock:
XAML 文件
<phone:PivotItem Header="Pivot 1">
<TextBlock Text="hello world" x:Name="dummytext" />
</phone:PivotItem>
CS文件
dummytext.Visibility = Visibility.Collapsed;
但是当我有以下代码时,我无法引用它:
XAML 文件
<phone:PivotItem Header="{Binding Dummy.Title}">
<Grid Margin="0,0,-12,0">
<ListBox x:Name="Box1">
<phone:LongListSelector ItemsSource="{Binding Dummy.Items}">
<phone:LongListSelector.ItemTemplate>
<DataTemplate>
<StackPanel>
<Grid>
//REFERENCE THIS TEXTBLOCK
<TextBlock Text="hello world" x:Name="dummytext" />
</Grid>
<Grid>
<TextBlock Text="byee world" x:Name="dummytext2" />
<TextBlock Text="bye2 world" x:Name="dummytext3" />
</Grid>
</StackPanel>
</DataTemplate>
</phone:LongListSelector.ItemTemplate>
</phone:LongListSelector>
</ListBox>
</Grid>
</phone:PivotItem>
我是 Windows Phone 开发的新手,还在学习。你能指出我哪里出错了吗?