Thanks a lot, Lyubo
I tried to use this method PreviewMouseWheel, and set e.Handled = true; but there is no response method PreviewMouseWheel, I do not know where to set it in place, what is missing? Please tell me how to modify it?
xaml:
<StackPanel>
<DockPanel>
<Label Content="PCB长度"/>
<RibbonTextBox Name="textBoxW" PreviewTextInput="tb_PreviewTextInput" InputMethod.IsInputMethodEnabled="False" PreviewMouseWheel="numberWheelchange" />
</DockPanel>
<DockPanel>
<Label Content="PCB宽度"/>
<RibbonTextBox Name="textBoxH" PreviewTextInput="tb_PreviewTextInput" InputMethod.IsInputMethodEnabled="False" PreviewMouseWheel="numberWheelchange" />
</DockPanel>
<DockPanel>
<Label Content="轨道宽度"/>
<RibbonTextBox/>
</DockPanel>
</StackPanel>
cs:
private void numberWheelchange(object sender, MouseWheelEventArgs e)
{
if (textBoxW.IsSelectionActive)
{
if (textBoxW.Text != null)
{
if (overlayNode == null)
return;
// this value is used only for demonstration, adjust as per your requirements
var delta = e.Delta > 0 ? 10 : -10;
var newBounds = new Rect(overlayNode.Bounds.X - delta, overlayNode.Bounds.Y, overlayNode.Bounds.Width + delta, overlayNode.Bounds.Height);
overlayNode.SetBounds(newBounds, true, true);
imageNode.InvalidateVisual();
textBoxW.Text = overlayNode.Bounds.Width.ToString();
}
}
if (textBoxH.IsSelectionActive)
{
if (textBoxH.Text != null)
{
if (overlayNode == null)
return;
// this value is used only for demonstration, adjust as per your requirements
var delta = e.Delta > 0 ? 10 : -10;
var newBounds = new Rect(overlayNode.Bounds.X, overlayNode.Bounds.Y - delta, overlayNode.Bounds.Width, overlayNode.Bounds.Height + delta);
overlayNode.SetBounds(newBounds, true, true);
imageNode.InvalidateVisual();
textBoxW.Text = overlayNode.Bounds.Width.ToString();
}
}
e.Handled = true;
}