CNC执行逻辑的开发,点击运行,停止
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace XplorePlane.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Attached behavior that calls BringIntoView() on a TreeViewItem
|
||||
/// whenever the AutoScroll property transitions to true.
|
||||
/// Bind to IsRunningNode to auto-scroll the executing node into view.
|
||||
/// </summary>
|
||||
public static class CncExecutionScrollBehavior
|
||||
{
|
||||
public static readonly DependencyProperty AutoScrollProperty =
|
||||
DependencyProperty.RegisterAttached(
|
||||
"AutoScroll",
|
||||
typeof(bool),
|
||||
typeof(CncExecutionScrollBehavior),
|
||||
new PropertyMetadata(false, OnAutoScrollChanged));
|
||||
|
||||
public static bool GetAutoScroll(DependencyObject obj)
|
||||
=> (bool)obj.GetValue(AutoScrollProperty);
|
||||
|
||||
public static void SetAutoScroll(DependencyObject obj, bool value)
|
||||
=> obj.SetValue(AutoScrollProperty, value);
|
||||
|
||||
private static void OnAutoScrollChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.NewValue is true && d is TreeViewItem item)
|
||||
{
|
||||
item.BringIntoView();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user