【发布时间】:2013-08-16 21:00:12
【问题描述】:
我有列表框,数据模板是按钮:
<ListBox x:Name="lbname" ItemsSource="{Binding myCollection}">
<ListBox.ItemTemplate>
<DataTemplate>
<Button x:Name="btnname" Content="{Binding name}" Click="btnname_Click">
<Button.Background>
<ImageBrush ImageSource="/myApplication;component/images/buttons/normal.png"/>
</Button.Background>
</Button>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
我有两个用于此列表框图像的图像背景(normal.png 用于正常模式,click.png 用于列表框中的选定项目)
按钮列表中的listBox视图项,按钮图片背景一般为normal.png
我的问题是如何将所选按钮的图像背景更改为 click.png 并将旧的选定按钮检索为 normal.png
如何通过每行按钮更改列表框中所选项目的图像背景?
希望这一点清楚,请我花大约一天的时间来讨论这个问题 谁能帮忙
谢谢
【问题讨论】:
标签: c# wpf listbox datatemplate