1
我有以下標記:WPF的RelativeSource問題與嵌套控件
<Button Name="m_SaveButton" Command="{Binding SaveCommand}">
<StackPanel>
<Image Source="{StaticResource IconSave16}">
<Image.Style>
<Style TargetType="Image">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=IsEnabled, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Button}}}" Value="False">
<Setter Property="Source" Value="{StaticResource IconSaveInactive16}" />
</DataTrigger>
</Style.Triggers>
</Style>
</Image.Style>
</Image>
<Label Content="Save" />
</StackPanel>
</Button>
我想改變嵌套在按鈕內部圖像時Button.IsEnabled是假的。上面的標記不起作用。
我試圖用Meleak的代碼在這裏找到:WPF Mouseover Trigger Effect for Child Controls
有誰可以建議我一個解決方案?
預先感謝您!
您是否嘗試過使用ElementName而不是RelativeSource進行綁定? – 2013-02-11 12:23:25
嗯..還沒有。我現在就試一試。 – papaiatis 2013-02-11 12:26:27
它也不起作用: ' ... DataTrigger>' –
papaiatis
2013-02-11 12:29:32