【发布时间】:2018-02-01 00:43:37
【问题描述】:
我正在尝试更改列表视图中所选项目的数据模板,我发现的所有内容都过于复杂或过时。 我尝试过使用行为,但它仍然不起作用。这就是我所追求的
<UserControl.Rescources>
<DataTemplate x:DataType="dt" x:Key="notselected">
<Grid>
<Textblock Text="{Binding Title}" Foreground="White"/>
<Image Source="ms-appx:///Assets/myimage.png"/>
</Grid>
</DataTemplate>
<DataTemplate x:DataType="dt" x:Key="selected">
<Grid>
<Textblock Text="{Binding Title}" Foreground="Black"/>
<Image Source="ms-appx:///Assets/myselectedimage.png"/>
</Grid>
</DataTemplate>
</UserControl.Rescources>
<ListView x:Name="listview" ItemTemplate="{StaticResource TMP1}">
<ListView.ItemContainerStyle>
<StaticResource ResourceKey="ListViewItemStyle1"/>
</ListView.ItemContainerStyle>
只是让它在选择时切换到 TMP2 这可能吗?
谢谢
【问题讨论】:
-
过去一个小时我一直在玩这个解决方案,但我无法让它工作
标签: xaml uwp win-universal-app uwp-xaml