0
工作我想要重写默认按钮样式,以便只有一个图像按钮,没有边框和所有的东西。VisualStateManager似乎不能与.NET 4.0(wpf)
这一切都工作完美,但虽然我定义了我的XAML样式的VisualStateManager,按钮不能用鼠标按下。事实上,它什么都不做。
我该怎么做?
<!-- Button Style -->
<Style x:Key="WinImageButton" TargetType="Button">
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Background" Value="Transparent"/>
<Setter Property="RenderTransform">
<Setter.Value>
<TranslateTransform/>
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<ContentControl x:Name="RootElement">
<ContentPresenter
HorizontalAlignment="Center"
VerticalAlignment="Center"
RecognizesAccessKey="True">
</ContentPresenter>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup Name="CommonStates">
<VisualState Name="Normal" />
<VisualState Name="Pressed">
<Storyboard>
<DoubleAnimation
Storyboard.TargetName="RootElement"
Storyboard.TargetProperty="(FrameworkElement.RenderTransform).(TranslateTransform.Y)"
To="2.0" />
<DoubleAnimation
Storyboard.TargetName="RootElement"
Storyboard.TargetProperty="(FrameworkElement.RenderTransform).(TranslateTransform.X)"
To="-2.0" />
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</ContentControl >
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
究竟是什么意思_按钮不能用鼠标按下?这是一个视觉问题吗?在点击按钮时你期望发生其他事情,但事实并非如此? –
我上面贴的样式是一个按钮样式。创建一个按钮并将其设置为上面的样式。按钮将显示(没有边框和所有东西),但点击该按钮将不会导致任何操作。但是,如果你看看VisualStateGroup,它应该被移动2个像素。 – BitKFu