[英]WPF/XAML Button.Template
我有點不解。 這不是什么大問題,但是有人對此有一個解釋嗎?
<Button Command="{Binding CancelButtonClickCommand}" DockPanel.Dock="Right" Height="16" Width="16">
<Button.Template>
<ControlTemplate>
<Grid Background="{Binding CancelImage}"/>
</ControlTemplate>
</Button.Template>
工作,當這個
<Button Command="{Binding CheckButtonClickCommand}" DockPanel.Dock="Left" Height="16" Width="16">
<Button.Template>
<ControlTemplate>
<Image Source="{Binding CheckImage}"/>
</ControlTemplate>
</Button.Template>
這么想的? 區別在於,我在第一個中使用<Grid Background="{Binding CancelImage}"/>
<Image Source="{Binding CheckImage}"/>
,在一個不起作用的<Image Source="{Binding CheckImage}"/>
使用<Image Source="{Binding CheckImage}"/>
。 在后者中,該圖像不可見,我什至都沒有調用Command。
非常感謝/ C
Grid.Background綁定到Brush
類型,而Image.Source需要一個ImageSource
。 解決該問題的最簡單方法是在CheckImage綁定中公開Brush的ImageSource
屬性。 如果不可能,您還可以將轉換器附加到Image.Source綁定,並從要綁定到的畫筆返回ImageSource。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.