我需要一些幫助,我從自定義按鈕上的樣式獲得綁定錯誤。 這裏是XAML:WPF圖像效果控件模板中的綁定錯誤
<Style TargetType="{x:Type Controls:DropDownButton}" BasedOn="{StaticResource ButtonBaseStyle}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Controls:DropDownButton}">
<Border
x:Name="border"
Padding="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
VerticalAlignment="{TemplateBinding VerticalAlignment}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid Grid.Column="0" >
<Border Padding="5">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Image
Style="{StaticResource DefaultImageStyle}"
Source="{Binding SmallImage, Converter={StaticResource LocalizingConverter}}">
<Image.Effect>
<ShaderEffects:GrayscaleEffect
DesaturationFactor="1"
IsEnabled="{Binding IsEnabled, RelativeSource={RelativeSource TemplatedParent}}"/>
</Image.Effect>
</Image>
</Grid>
<Grid Grid.Row="1">
<TextBlock
Style="{StaticResource DefaultTextHeaderStyle}"
Text="{Binding Name, Converter={StaticResource LocalizingConverter}}"/>
</Grid>
</Grid>
</Border>
</Grid>
<Grid
Grid.Column="1"
VerticalAlignment="Stretch">
<Polygon
x:Name="arrow"
Points="0,0 8,0 4,5"
Fill="{TemplateBinding Foreground}"
VerticalAlignment="Center"
HorizontalAlignment="Center"/>
</Grid>
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
,當應用程序啓動時給了我下面的綁定錯誤:
System.Windows.Data Error: 2 : Cannot find governing FrameworkElement or FrameworkContentElement for target element. BindingExpression:Path=IsEnabled; DataItem=null; target element is 'GrayscaleEffect' (HashCode=4769001); target property is 'IsEnabled' (type 'Boolean')
的圖像效果似乎工作正常,但最新的成交與綁定錯誤我該如何解決它?
是的,當按鈕被禁用時,效果肯定會被應用。 – Sigh 2011-04-11 03:52:47