C# Items控件内的访问按钮
我在windows应用商店项目中有此代码C# Items控件内的访问按钮,c#,xaml,windows-runtime,windows-store,C#,Xaml,Windows Runtime,Windows Store,我在windows应用商店项目中有此代码 <ItemsControl Name="ItemStuff"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <StackPanel Orientation="Horizontal"></StackPanel>
<ItemsControl Name="ItemStuff">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"></StackPanel>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="lala" Foreground="White" Tapped="SomeFunc"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
我将ItemsControl的items.source设置为包含6项的列表,
当我点击textblock时,我将文本的前景色更改为红色,但我想将其他按钮设置为白色,我如何从点击的事件函数访问其他按钮,以便当我按下第三项的文本时,第一项已为红色,它将第三个变为红色,第一个变为白色。您可以使用
ListBox
代替ItemsControl
,因为它提供了选择功能并更改ListBoxItem.Template
,当选择它时,它将变为Background
红色
现在停下来学习MVVM。在没有MVVM的情况下使用XAML非常痛苦。我想访问函数中的6个TextBlock控件,不知道这与MVVM有什么关系。如果使用MVVM,就不会有这个问题。@Ric,为什么不使用单选的ListBox
?我需要将标题(TexBlocks中的文本)并排放置,我可以用ListBox吗?