我有使用VisualStateManger的按钮样式。目前这些款式在<Grid.Resources>
并且没有任何错误地工作。我试图将这些样式移动到资源字典中,并提供以下错误。任何人都知道为什么它在样式处于用户控制内时工作而在移动到资源字典时不工作。无法将按钮样式与VisualStateManger.VisualStateGroup添加到资源字典
标签 'visualstatemanager.visualstategroups' 不存在XML命名空间 http://schemas.microsoft.com/winfx/2006/xaml/presentation
我使用.net 3.5
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vsm="clr-namespace:System.Windows;assembly=wpftoolkit"
xmlns:system="clr-namespace:System;assembly=mscorlib"
>
<Style x:Key="Home" BasedOn="{StaticResource PagingButton}" TargetType="{x:Type Button}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType='Button'>
<Border Name='border' Background='{StaticResource HomeButtonBackground}' CornerRadius='5,5,0,0'>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" >
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(Border.Background)" Storyboard.TargetName="border">
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ButtonBackground}"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Pressed">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(Border.Background)" Storyboard.TargetName="border">
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource ButtonBackgroundPressed}"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
请发表您的资源字典XAML – GazTheDestroyer
这是编译错误或设计师只有错误? –
@RohitVats它的运行时错误 – Sampath