本文整理汇总了C#中System.Windows.VisualStateGroup.SetValue方法的典型用法代码示例。如果您正苦于以下问题:C# VisualStateGroup.SetValue方法的具体用法?C# VisualStateGroup.SetValue怎么用?C# VisualStateGroup.SetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.VisualStateGroup
的用法示例。
在下文中一共展示了VisualStateGroup.SetValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ManagedVisualStates
public void ManagedVisualStates ()
{
Rectangle r = new Rectangle { Name = "rect", Width = 0 };
VisualStateGroup group = new VisualStateGroup ();
group.SetValue (FrameworkElement.NameProperty, "group");
VisualState vstate = new VisualState ();
vstate.SetValue (FrameworkElement.NameProperty, "state");
DoubleAnimation anim = new DoubleAnimation { From = 100, To = 200, Duration = TimeSpan.FromSeconds (1) };
anim.SetValue (Control.NameProperty, "ANIMATION");
Storyboard.SetTargetName (anim, "rect");
Storyboard.SetTargetProperty (anim, new PropertyPath ("Width"));
Storyboard sb = new Storyboard ();
sb.Children.Add (anim);
vstate.Storyboard = sb;
group.States.Add (vstate);
Enqueue (() => TestPanel.Children.Add (r));
Enqueue (() => VisualStateManager.GetVisualStateGroups ((FrameworkElement)TestPanel.Parent).Add (group));
Enqueue (() => Assert.AreEqual(0, r.Width, "#1"));
Enqueue (() => Assert.IsTrue (VisualStateManager.GoToState ((Control) TestPage, "state", false), "#2"));
Enqueue (() => Assert.IsGreater (99, r.Width, "#3"));
Enqueue (() => TestPanel.Children.Clear ());
Enqueue (() => VisualStateManager.GetVisualStateGroups (TestPage).Clear ());
EnqueueTestComplete();
}
示例2: AddNotificationStatesGroup
/// <summary>
/// Adds the notification states group.
/// </summary>
/// <param name="popupView">The popup view.</param>
/// <param name="panel">The panel.</param>
private void AddNotificationStatesGroup(PopupView popupView, Panel panel)
{
var uniqueId = Guid.NewGuid();
var groups = (IList<VisualStateGroup>)VisualStateManager.GetVisualStateGroups(_panel);
var vsGroup = new VisualStateGroup();
groups.Add(vsGroup);
vsGroup.SetValue(FrameworkElement.NameProperty, string.Format(CultureInfo.InvariantCulture, "NotificationState{0}", uniqueId));
var hideState = new VisualState();
var showState = new VisualState();
var showCenterState = new VisualState();
var showBusyState = new VisualState();
var showStoryboard = new Storyboard();
if (_position == PopupPosition.Top)
PopupHelper.AddFlipFromTopAnimation(showStoryboard, popupView);
else
PopupHelper.AddSlideFromLeftAnimation(showStoryboard, popupView);
showStoryboard.Completed += (o, args) =>
{
if (_duration == 0)
return;
_timer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(_duration) };
_timer.Start();
_timer.Tick += (sender, eventArgs) =>
{
if (!_isMouseOver)
HideNotificationPopup(_timer);
else
_timeToClose = true;
};
};
showState.Storyboard = showStoryboard;
var hideStoryboard = new Storyboard();
switch (_position)
{
case PopupPosition.Right:
hideStoryboard.Children.Add(PopupHelper.GetSlideToRightAnimation(popupView));
break;
case PopupPosition.Top:
PopupHelper.AddFlipToTopAnimation(hideStoryboard, popupView);
break;
default:
hideStoryboard.Children.Add(PopupHelper.GetOpacityZeroAnimation(popupView));
break;
}
_removeControlsAction = () =>
{
panel.Children.Remove(popupView);
groups.Remove(vsGroup);
if (_modalBorder != null)
_parentPanel.Children.Remove(_modalBorder);
};
hideStoryboard.Completed += (o, args) => RemoveControls();
hideState.Storyboard = hideStoryboard;
var showCenterStoryboard = new Storyboard();
showCenterState.Storyboard = showCenterStoryboard;
var showBusyStoryboard = new Storyboard();
showBusyState.Storyboard = showBusyStoryboard;
_showName = string.Format(CultureInfo.InvariantCulture, "Show{0}", uniqueId);
_hideName = string.Format(CultureInfo.InvariantCulture, "Hide{0}", uniqueId);
_showCenterName = string.Format(CultureInfo.InvariantCulture, "ShowCenter{0}", uniqueId);
_showBusyName = string.Format(CultureInfo.InvariantCulture, "ShowBusy{0}", uniqueId);
showState.SetValue(FrameworkElement.NameProperty, _showName);
hideState.SetValue(FrameworkElement.NameProperty, _hideName);
showCenterState.SetValue(FrameworkElement.NameProperty, _showCenterName);
showBusyState.SetValue(FrameworkElement.NameProperty, _showBusyName);
vsGroup.States.Add(showState);
vsGroup.States.Add(showCenterState);
vsGroup.States.Add(hideState);
vsGroup.States.Add(showBusyState);
}
示例3: ManagedVisualStates2
public void ManagedVisualStates2 ()
{
Rectangle r = new Rectangle { Width = 0 };
VisualStateGroup group = new VisualStateGroup ();
group.SetValue (FrameworkElement.NameProperty, "group2");
// Create the first visual state
VisualState vstate = new VisualState ();
vstate.SetValue (FrameworkElement.NameProperty, "state2");
DoubleAnimation anim = new DoubleAnimation { From = 100, To = 200, Duration = TimeSpan.FromSeconds (1) };
Storyboard.SetTarget (anim, r);
Storyboard.SetTargetProperty (anim, new PropertyPath ("Width"));
Storyboard sb = new Storyboard ();
sb.Children.Add (anim);
vstate.Storyboard = sb;
group.States.Add (vstate);
// Create the second visual state
VisualState vstate2 = new VisualState ();
vstate2.SetValue (FrameworkElement.NameProperty, "state3");
Storyboard sb2 = new Storyboard ();
Storyboard.SetTarget (sb2, r);
Storyboard.SetTargetProperty (sb2, new PropertyPath ("Width"));
vstate2.Storyboard = sb2;
group.States.Add (vstate2);
// Ensure that the values reset correct
Enqueue (() => TestPanel.Children.Add (r));
Enqueue (() => VisualStateManager.GetVisualStateGroups ((FrameworkElement)TestPanel.Parent).Add (group));
Enqueue (() => Assert.AreEqual(0, r.Width, "#1"));
Enqueue (() => Assert.IsTrue (VisualStateManager.GoToState (TestPage, "state2", false), "#2"));
Enqueue (() => Assert.IsGreater (99, r.Width, "#3"));
Enqueue (() => Assert.IsTrue (VisualStateManager.GoToState (TestPage, "state3", false), "#3"));
Enqueue (() => Assert.AreEqual (0, r.Width, "#4"));
Enqueue (() => Assert.AreEqual (ClockState.Filling, sb2.GetCurrentState (), "#5"));
Enqueue (() => TestPanel.Children.Clear ());
Enqueue (() => VisualStateManager.GetVisualStateGroups (TestPage).Clear ());
EnqueueTestComplete();
}