【发布时间】:2020-10-27 15:50:58
【问题描述】:
我有一个包含图像路径的组合框,我需要使用选定的路径作为图像对象的源。我试过这样绑定它:
...
<Border BorderBrush="Black" BorderThickness="1" Grid.Row="0" Grid.Column="2" Grid.RowSpan="3" Width="50" Height="50" Margin="10, 10, 10, 6" VerticalAlignment="Bottom">
<Image Name="Image" Source="{Binding ElementName=ComboBox, Path=SelectedItem.Value, UpdateSourceTrigger=PropertyChanged}"/>
</Border>
...
<ComboBox Name="ComboBox" Grid.Row="2" Grid.Column="1" Margin="4" VerticalAlignment="Center">
<ComboBoxItem IsSelected="True">Images/men.png</ComboBoxItem>
<ComboBoxItem>Images/women.png</ComboBoxItem>
</ComboBox>
...
我做错了什么?
【问题讨论】:
标签: c# wpf xaml data-binding