我想覆蓋我的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