我有使用VisualStateManger的按钮样式。目前,这些样式在<Grid.Resources>中运行,没有任何错误。我试图将这些样式移到资源字典中,它会产生以下错误。任何人都知道,当样式在用户控件中,而在移动到资源字典时,它为什么会工作。
在XML命名空间http://schemas.microsoft.com/winfx/2006/xaml/presentation中不存在标记‘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>发布于 2014-03-19 16:50:53
问题是,您正在尝试使用程序集中没有引用的内容。您需要将其添加到根的窗口/页标记中,其他名称空间如下
xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows"然后你就可以把它当作
<vsm:VisualStateManager.VisualStateGroups>
<vsm:VisualStateGroup x:Name="CommonStates">
<vsm:VisualState x:Name="MouseOver">
<Storyboard>
<ColorAnimation Storyboard.TargetName="tickBox"
Storyboard.TargetProperty="(Rectangle.Fill).
(SolidColorBrush.Color)"
To="PaleGreen" Duration="0:0:0.5" />
</Storyboard>
</vsm:VisualState>
</vsm:VisualStateGroup>
</vsm:VisualStateManager.VisualStateGroups>https://stackoverflow.com/questions/22512615
复制相似问题