我有一个自定义控件类型,如:<Grid> ... </Grid>
和Grid.BitmapEffect属性。如何通过C#代码(例如事件)在此控件(网格)中更改BitmapEffetc?如何通过C#代码更改自定义WPF控件中的BitmapEffect
代码示例 - 自定义控件的一部分:
[...]
<Grid Background="#FFE5AA">
<Grid.RowDefinitions>
<RowDefinition Height="62*"/>
<RowDefinition Height="15*"/>
<RowDefinition Height="23*"/>
</Grid.RowDefinitions>
<Grid.BitmapEffect>
<OuterGlowBitmapEffect GlowColor="#459E5A" GlowSize="13" Noise="0" Opacity="0.9" />
</Grid.BitmapEffect>
<Border Grid.Column="0" Grid.Row="0" Grid.RowSpan="3" BorderBrush="#F5B903" BorderThickness="1,1,1,1" >
</Border>
[...]
然后在Window.xaml:
<controls:MyControl Name="Control1" Cursor="Hand" MouseDown="Control1_MouseDown" />
然后在C#:
private void Control1_MouseDown(object sender, MouseButtonEventArgs e)
{
//there i want to change Control1.BitmapEffect
}
它不起作用。 – Kamilos 2009-12-16 13:23:51
我刚试过,它工作正常。你能提供一个简短的例子来重现这个问题吗? – Heinzi 2009-12-16 14:39:30
好的,看上面。 – Kamilos 2009-12-16 14:51:07