用BindingProxy类修正TranslateX和RotateAngle绑定失败

This commit is contained in:
SIC1016\caipeilun 2024-03-19 16:42:22 +08:00
parent 4103804b41
commit 82b739b309
2 changed files with 17 additions and 7 deletions

View File

@ -4,12 +4,16 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Common="clr-namespace:SicUI.Controls.Common"
xmlns:controls="clr-namespace:SicUI.Controls"
xmlns:extendedControls="clr-namespace:MECF.Framework.UI.Core.ExtendedControls;assembly=MECF.Framework.UI.Core"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:SicUI.Controls.M2C4Parts"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
d:DesignHeight="38"
d:DesignWidth="416"
mc:Ignorable="d">
<UserControl.Resources>
<extendedControls:BindingProxy x:Key="proxy" Data="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=UserControl}}"/>
</UserControl.Resources>
<Viewbox Stretch="Uniform">
<Canvas
x:Name="root"
@ -66,8 +70,8 @@
</Common:AxisCanvas>
<Canvas.RenderTransform>
<TransformGroup>
<RotateTransform Angle="{Binding RotateAngle}" CenterY="30" />
<TranslateTransform x:Name="translate" X="{Binding TranslateX}" />
<RotateTransform Angle="{Binding Source={StaticResource proxy},Path=Data.RotateAngle}" CenterY="30" />
<TranslateTransform x:Name="translate" X="{Binding Source={StaticResource proxy},Path=Data.TranslateX}" />
</TransformGroup>
</Canvas.RenderTransform>
</Canvas>

View File

@ -48,19 +48,25 @@ namespace SicUI.Controls.M2C4Parts
public static readonly DependencyProperty ShowDockProperty =
DependencyProperty.Register("ShowDock", typeof(bool), typeof(AtmRobotMultiLP), new PropertyMetadata(false));
public double RotateAngle
{
get { return (double)GetValue(RotateAngleProperty); }
set { SetValue(RotateAngleProperty, value); }
}
// Using a DependencyProperty as the backing store for RotateAngel. This enables animation, styling, binding, etc...
public static readonly DependencyProperty RotateAngleProperty =
DependencyProperty.Register("RotateAngel", typeof(int), typeof(AtmRobotMultiLP), new PropertyMetadata(0));
DependencyProperty.Register("RotateAngel", typeof(double), typeof(AtmRobotMultiLP), new PropertyMetadata(0.0));
public int TranslateX
public double TranslateX
{
get { return (int)GetValue(TranslateXProperty); }
get { return (double)GetValue(TranslateXProperty); }
set { SetValue(TranslateXProperty, value); }
}
// Using a DependencyProperty as the backing store for TranslateX. This enables animation, styling, binding, etc...
public static readonly DependencyProperty TranslateXProperty =
DependencyProperty.Register("TranslateX", typeof(int), typeof(AtmRobotMultiLP), new PropertyMetadata(0));
DependencyProperty.Register("TranslateX", typeof(double), typeof(AtmRobotMultiLP), new PropertyMetadata(0.0));
public MECF.Framework.UI.Client.ClientBase.WaferInfo Wafer1
{
@ -335,7 +341,7 @@ namespace SicUI.Controls.M2C4Parts
m.Items.Add(new MenuItem() { Header = "Move", Command = self.MoveCommand, CommandParameter = new RobotMoveInfo() { BladeTarget = position.Key, Action = RobotAction.Moving, ArmTarget = arm } });
menus.Add(m);
}
self.Menu = menus;
//self.Menu = menus;
self.MoveTo(new RobotMoveInfo() { BladeTarget = positions.First().Key, Action = RobotAction.None });
}