我的目标是在旋转3D模型后将xAngle
保存在我的ViewModel
中。
由于某些原因,properties
ViewModel
我在这里缺少什么?
这是我的代码:
我在 xaml :
中有以下代码<Window.DataContext>
<Local:VM />
</Window.DataContext>
<helix:HelixViewport3D x:Name="viewPort3d" ZoomExtentsWhenLoaded="true" CameraRotationMode="Trackball"
ShowCoordinateSystem="True" RotateGesture="{Binding RotateGesture, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
>
<helix:SpotHeadLight/>
<ModelVisual3D Content="{Binding The3dModel.Content, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
<ModelVisual3D.Transform>
<Transform3DGroup>
<RotateTransform3D>
<RotateTransform3D.Rotation>
<AxisAngleRotation3D Axis="1,0,0" Angle="{Binding xAngle, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
</RotateTransform3D.Rotation>
</RotateTransform3D>
</Transform3DGroup>
</ModelVisual3D.Transform>
</ModelVisual3D>
</helix:HelixViewport3D>
ViewModel 中的以下代码:
public class VM : INotifyPropertyChanged
{
private int m_xAngle;
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); }
public int xAngle
{
get => m_xAngle;
set
{
m_xAngle = value;
OnPropertyChanged();
}
}
}