Re: The attachable property 'VisualStateGroups' was not found in type 'VisualStateManager'.
Hi,
I've found another workaround to avoid the warning/error and the broken Design View inside Studio :
- Design everything you need with Blend.
- Comment out the VisualStateManager Part in the XAML file.
- Create the VisualStateManager dynamically inside your code behind class
Regards,
Stefan
This is my XAML:
---------------------------
<vsm:VisualStateManager.VisualStateGroups>
<vsm:VisualStateGroup x:Name="MouseOverStates">
<vsm:VisualState x:Name="MouseEnter">
<Storyboard>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="LayoutRoot" Storyboard.TargetProperty="(UIElement.Opacity)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0.5"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</vsm:VisualState>
<vsm:VisualState x:Name="MouseLeave">
<Storyboard/>
</vsm:VisualState>
</vsm:VisualStateGroup>
This is my code:
------------------------
Friend WithEvents vsMouseOverStates As System.Windows.VisualStateGroup
Friend WithEvents vsMouseEnter As System.Windows.VisualState
Friend WithEvents vsMouseLeave As System.Windows.VisualState
Public Sub New()
InitializeComponent()
vsMouseOverStates = New VisualStateGroup
vsMouseEnter = New VisualState
vsMouseLeave = New VisualState
Dim vsStoryboard As New Storyboard
vsMouseOverStates.SetValue(NameProperty, "MouseOverStates")
vsMouseEnter.SetValue(NameProperty, "MouseEnter")
vsMouseLeave.SetValue(NameProperty, "MouseLeave")
vsMouseOverStates.States.Add(vsMouseEnter)
vsMouseOverStates.States.Add(vsMouseLeave)
vsMouseEnter.Storyboard = vsStoryboard
VisualStateManager.GetVisualStateGroups(LayoutRoot).Add(vsMouseOverStates)
Dim vsDoubleAnimationUsingKeyFrames As New DoubleAnimationUsingKeyFrames
vsDoubleAnimationUsingKeyFrames.BeginTime = New TimeSpan(0)
vsDoubleAnimationUsingKeyFrames.Duration = New Duration(New TimeSpan(0, 0, 0, 0, 10))
vsDoubleAnimationUsingKeyFrames.SetValue(Storyboard.TargetNameProperty, "LayoutRoot")
vsDoubleAnimationUsingKeyFrames.SetValue(Storyboard.TargetPropertyProperty, New PropertyPath("Opacity"))
vsStoryboard.Children.Add(vsDoubleAnimationUsingKeyFrames)
Dim vsSplineDoubleKeyFrame As New SplineDoubleKeyFrame
vsSplineDoubleKeyFrame.Value = 0.5
vsSplineDoubleKeyFrame.KeyTime = KeyTime.FromTimeSpan(New TimeSpan(0))
vsDoubleAnimationUsingKeyFrames.KeyFrames.Add(vsSplineDoubleKeyFrame)
End Sub
Stefan