Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Made FollowObservableStateBehavior more flexible.

VisualStateManager.GoToElementState is used when the target is not a
Control (e.g. your visual states are on a Window) as per MSDN.
  • Loading branch information...
commit 67422de5982d9c732f8e074bb14199be6a21dd96 1 parent dd987b0
Dev Knoll authored paulcbetts committed
Showing with 13 additions and 2 deletions.
  1. +13 −2 ReactiveUI.Blend/FollowObservableStateBehavior.cs
View
15 ReactiveUI.Blend/FollowObservableStateBehavior.cs
@@ -60,14 +60,25 @@ protected override void OnDetaching()
protected static void onStateObservableChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
{
- FollowObservableStateBehavior This = (FollowObservableStateBehavior)sender;
+ var This = (FollowObservableStateBehavior)sender;
if (This.watcher != null) {
This.watcher.Dispose();
This.watcher = null;
}
This.watcher = ((IObservable<string>)e.NewValue).ObserveOn(RxApp.DeferredScheduler).Subscribe(
- x => VisualStateManager.GoToState(This.TargetObject ?? This.AssociatedObject, x, true),
+ x => {
+ var target = This.TargetObject ?? This.AssociatedObject;
+#if SILVERLIGHT
+ VisualStateManager.GoToState(target, x, true);
+#else
+ if (target is Control) {
+ VisualStateManager.GoToState(target, x, true);
+ } else {
+ VisualStateManager.GoToElementState(target, x, true);
+ }
+#endif
+ },
ex => {
if (!This.AutoResubscribeOnError)
return;
Please sign in to comment.
Something went wrong with that request. Please try again.