-1
我遇到了WPF的一些问题,我想知道是否有人知道我应该尝试下一步。所以基本上我有一个处理窗口,它绑定到一个字符串列表,并且每个窗口都获得一个ListBox中的图像。WPF图片更新
我到目前为止的代码如下。
<ListBox x:Name="MyListBox" ItemsSource="{Binding Items}" Margin="36,100,320,100" SelectedIndex="0" Panel.ZIndex="1" MouseDoubleClick="MyListBox_MouseDoubleClick">
<ListBox.Resources>
<BitmapImage x:Key="checkmark" UriSource="Images/checkmark.gif" />
<BitmapImage x:Key="failure" UriSource="Images/red-x.gif" />
<BitmapImage x:Key="processing" UriSource="Images/processing.gif" />
<BitmapImage x:Key="white" UriSource="Images/white.gif" />
</ListBox.Resources>
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Image Source="{DynamicResource white}" />
<TextBlock Text="{Binding}" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
我试过以下多个在线文章,但我似乎无法将我的资源从白色更改为任何其他键。所以我认为我的下一步是将动态资源指向一个决定每个对象状态的类,但我似乎无法得到它来更新任何图像。
我已经试过 MyListBox.SelectedItem = MyListBox.FindResource("checkmark"); MyListBox.InvalidateArrange(); MyListBox.UpdateLayout();
和一堆别人的,但它似乎并没有做太多。 我是WPF的新手,所以我为新手问题表示歉意,但任何帮助或推动正确的方向将是非常有帮助的。提前致谢。
这是非常有用的非常感谢你! – Xander
乐于助人。我知道如何开始一个新的语言/框架可能会令人沮丧。 – evanb