我想覆盖我的BoardSquares
上的图像,但是当试图在我的Image
上指定Source
时,它说The member "Source" is not recognized or is not accessible
。任何想法我可能做错了什么? P.S我省略了DataTemplate触发器,但他们在那里。WPF图片来源无法识别或无法访问
<ItemsControl ItemsSource="{Binding BoardGUI.BoardSquares}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<UniformGrid Rows="10" Columns="10"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Button x:Name="Square"
Command="{Binding DataContext.BoardGUI.SquareClickCommand, RelativeSource={RelativeSource AncestorType=ItemsControl}}"
CommandParameter="{Binding}">
<Button.Template>
<ControlTemplate TargetType="Button">
<Grid Background="{TemplateBinding Background}">
<Image Source="{TemplateBinding Source}"/>
</Grid>
</ControlTemplate>
</Button.Template>
</Button>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
Button类没有Source属性,'{TemplateBinding来源}'将无法工作。这是什么'源'? – ASh