/// <summary> /// Initializes a new instance of the <see cref="VisualStateProxyBinder"/> class. /// </summary> /// <param name="Proxy">The proxy.</param> /// <param name="binding">The binding.</param> /// <param name="dispose">The dispose.</param> private VisualStateProxyBinder(VisualStateProxy Proxy, Action <VisualStateProxyBinder> binding = null, Action <VisualStateProxyBinder> dispose = null) : base( binding, dispose ) { _Proxy = Proxy; }
//static Action <VisualStateProxyBinder > binding // = binder => // { // if (binder.Element != null) // { // act = // () => // { // binder._Proxy.GotoState(binder._Proxy.CurrentState, binder._Proxy.CurrentUseTransitions); // }; // } // }; /// <summary> /// Creates the specified proxy. /// </summary> /// <param name="proxy">The proxy.</param> /// <returns>VisualStateProxyBinder.</returns> public static VisualStateProxyBinder Create(VisualStateProxy proxy) { var binder = new VisualStateProxyBinder(proxy); RoutedEventHandler hdler = (o, ea) => { binder._Proxy.GotoState(binder._Proxy.CurrentState, binder._Proxy.CurrentUseTransitions); }; binder._bindingAction = b => { if (b.Element != null) { b.Element.Loaded += hdler; b.Element.Unloaded += (_1, _2) => { b.Element.SetValue(VisualStateProxyBinder.BinderProperty, null); }; } hdler(null, null); }; binder._disposeAction = b => { if (b.Element != null) { b.Element.Loaded -= hdler; } b.Element = null; }; return(binder); }