我的目标是在旋转 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();
}
}
}