VisualStateManager Storyboard Start/Stop

Feb 21, 2012 at 9:34 PM
Edited Feb 21, 2012 at 9:35 PM

I've been trying to get the visualstatemanager to work with caliburn micro

I found several blogs about it but nothing concrete, especially with caliburn micro.

If anyone has a demo code available or an example on how to perform this with CM i'd appreciate it.

 

i have currently in my view:

 

 local:VisualStates.CurrentState="{Binding Path=CurrentState}" 
	SupportedOrientations="Portrait" Orientation="Portrait"
	shell:SystemTray.IsVisible="True">
    <VisualStateManager.VisualStateGroups>
        <VisualStateGroup>
            <VisualState x:Name="Shown" >
                <Storyboard >

 

 

 

In my viewmodel:

 

 public constructor ()
        {

            CurrentState = "Shown";

 

and also

 

 

private string _CurrentState;

        public string CurrentState
        {
            get { return _CurrentState; }
            set { _CurrentState = value; NotifyOfPropertyChange(() => CurrentState); }
        }
        


 

and also a helper class:

 

 public static class VisualStates
    {
        public static readonly DependencyProperty CurrentStateProperty =
            DependencyProperty.RegisterAttached("CurrentState", typeof(String), typeof(VisualStates), new PropertyMetadata(TransitionToState));

        public static string GetCurrentState(DependencyObject obj)
        {
            return (string)obj.GetValue(CurrentStateProperty);
        }

        public static void SetCurrentState(DependencyObject obj, string value)
        {
            obj.SetValue(CurrentStateProperty, value);
        }

        private static void TransitionToState(object sender, DependencyPropertyChangedEventArgs args)
        {
            Control c = sender as Control;
            if (c != null)
            {
                VisualStateManager.GoToState(c, (string)args.NewValue, true);
            }
            else
            {
                throw new ArgumentException("CurrentState is only supported on the Control type");
            }
        }
    }

Coordinator
Feb 21, 2012 at 9:35 PM

If you can create a simple sample solution the reproduces the problem, please create a ticket and attach it so I can have a look. Thanks.

Feb 22, 2012 at 11:01 AM
EisenbergEffect wrote:

If you can create a simple sample solution the reproduces the problem, please create a ticket and attach it so I can have a look. Thanks.

 

Done: http://caliburnmicro.codeplex.com/workitem/211

 

Thanks Rob!