2
私は、ItemTemplate
のListBox
といくつかのデータバインディング(Imageを含む)を持っています。WPF Image Source Binding
ItemsSource
がコードビハインドに設定されています。画像ソースにバインドされているオブジェクトのメンバーを更新することによって、画像のソースを変更しようとするまで、すべてが期待どおりに機能します。私は間違って何をしていますか?ここで
はXAMLです:
<ListBox x:Name="myList" MouseDoubleClick="myList_MouseDoubleClick" ScrollViewer.VerticalScrollBarVisibility="Disabled">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Orientation="Vertical" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<Border BorderBrush="DarkGray" BorderThickness="1">
<StackPanel Orientation="Horizontal" Width="100">
<Image Width="38" Height="38" Source="{Binding Path=icon}" />
<StackPanel Width="100">
<Label Content="{Binding Path=name}" />
<Label Content="{Binding Path=state}" />
</StackPanel>
</StackPanel>
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
分離コードのいくつかの部分:
Window_Initialized
で:
myList_MouseDoubleClick
で
myList.ItemsSource = myLineList;
:
Line aLine = myList.SelectedItem as Line;
if (aLine != null) {
aLine.icon = "idle.jpg";
}
ありがとうございました。 mfcから来て、またadobeのフラッシュをコード化して私は当然これを取った... –