<ModelVisual3D x:Class="OrbitalSimulator.View.OrbitModelVisual3D" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" mc:Ignorable="d" x:Name="Model"> <ModelVisual3D.Transform> <Transform3DGroup> <ScaleTransform3D ScaleX="{Binding Scale.X, ElementName=Model}" ScaleY="{Binding Scale.Y, ElementName=Model}" ScaleZ="{Binding Scale.Z, ElementName=Model}"/> <RotateTransform3D> <RotateTransform3D.Rotation> <AxisAngleRotation3D Angle="{Binding EulerAngles.Yaw, ElementName=Model}" Axis="0 0 1" /> </RotateTransform3D.Rotation> </RotateTransform3D> <RotateTransform3D> <RotateTransform3D.Rotation> <AxisAngleRotation3D Angle="{Binding EulerAngles.Pitch, ElementName=Model}" Axis="0 1 0" /> </RotateTransform3D.Rotation> </RotateTransform3D> <RotateTransform3D> <RotateTransform3D.Rotation> <AxisAngleRotation3D Angle="{Binding EulerAngles.Roll, ElementName=Model}" Axis="1 0 0" /> </RotateTransform3D.Rotation> </RotateTransform3D> <TranslateTransform3D OffsetX="{Binding Radius, ElementName=Model}"/> <RotateTransform3D> <RotateTransform3D.Rotation> <AxisAngleRotation3D Axis="{Binding OrbitAxis, ElementName=Model}" Angle="{Binding CourseAngle, ElementName=Model}" /> </RotateTransform3D.Rotation> </RotateTransform3D> <RotateTransform3D> <RotateTransform3D.Rotation> <AxisAngleRotation3D Axis="0 1 0" Angle="{Binding Latitude, ElementName=Model}" /> </RotateTransform3D.Rotation> </RotateTransform3D> <RotateTransform3D> <RotateTransform3D.Rotation> <AxisAngleRotation3D Axis="0 0 1" Angle="{Binding Longitude, ElementName=Model}" /> </RotateTransform3D.Rotation> </RotateTransform3D> </Transform3DGroup> </ModelVisual3D.Transform> 

  public partial class OrbitModelVisual3D : ModelVisual3D { public OrbitModelVisual3D() { InitializeComponent(); } public Vector3D OrbitAxis { get { return (Vector3D)GetValue(OrbitAxisProperty); } set { SetValue(OrbitAxisProperty, value); } } public static readonly DependencyProperty OrbitAxisProperty = DependencyProperty.Register("OrbitAxis", typeof(Vector3D), typeof(OrbitModelVisual3D)); public double Radius { get { return (double)GetValue(RadiusProperty); } set { SetValue(RadiusProperty, value); } } public static readonly DependencyProperty RadiusProperty = DependencyProperty.Register("Radius", typeof(double), typeof(OrbitModelVisual3D)); public EulerAngles EulerAngles { get { return (EulerAngles)GetValue(EulerAnglesProperty); } set { SetValue(EulerAnglesProperty, value); } } public static readonly DependencyProperty EulerAnglesProperty = DependencyProperty.Register("EulerAngles", typeof(EulerAngles), typeof(OrbitModelVisual3D)); public Point3D Scale { get { return (Point3D)GetValue(ScaleProperty); } set { SetValue(ScaleProperty, value); } } public static readonly DependencyProperty ScaleProperty = DependencyProperty.Register("Scale", typeof(Point3D), typeof(OrbitModelVisual3D)); public double Longitude { get { return (double)GetValue(LongitudeProperty); } set { SetValue(LongitudeProperty, value); } } public static readonly DependencyProperty LongitudeProperty = DependencyProperty.Register("Longitude", typeof(double), typeof(OrbitModelVisual3D)); public double Latitude { get { return (double)GetValue(LatitudeProperty); } set { SetValue(LatitudeProperty, value); } } public static readonly DependencyProperty LatitudeProperty = DependencyProperty.Register("Latitude", typeof(double), typeof(OrbitModelVisual3D)); public double CourseAngle { get { return (double)GetValue(CourseAngleProperty); } set { SetValue(CourseAngleProperty, value); } } public static readonly DependencyProperty CourseAngleProperty = DependencyProperty.Register("CourseAngle", typeof(double), typeof(OrbitModelVisual3D)); } 

Example of using control:

 <l:OrbitModelVisual3D Scale="0.005 0.005 0.005" Radius="{Binding OrbitModel.CurrentPosition.Radius}" Longitude="{Binding OrbitModel.StartPoint.Longitude}" Latitude="{Binding OrbitModel.StartPoint.Latitude}" CourseAngle="{Binding OrbitModel.CurrentPosition.OrbitAngle}" OrbitAxis="{Binding OrbitModel.OrbitAxis}"> <t:FileModelVisual3D Source="3dsModels/tdrs_no_ants.3ds"/> </l:OrbitModelVisual3D> 

The program compiles, neither errors nor warnings, just the transmitted data is not bandaged, but when I use ScaleX="{Binding Path=Scale.X, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ModelVisual3D}}} instead of ScaleX="{Binding Scale.X, ElementName=Model} ScaleX="{Binding Path=Scale.X, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ModelVisual3D}}} , then everything works.

Closed due to the fact that off-topic participants aleksandr barakin , Bald , Ivan Pshenitsyn , user194374, dirkgntly Aug 21 '16 at 8:08 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • “Questions asking for help with debugging (“ why does this code not work? ”) Should include the desired behavior, a specific problem or error, and a minimum code for playing it right in the question . Questions without an explicit description of the problem are useless for other visitors. See How to create minimal, self-sufficient and reproducible example . " - aleksandr barakin, Bald, Ivan Pshenitsyn, Community Spirit, dirkgntly
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • one
    And what does “not working” mean? Not compiled? Crashes at runtime? If it does not work the way you expect, explain how you use the control and what exactly is happening. - VladD
  • The program compiles, neither errors nor warnings, just the transmitted data is not bandaged, but when I use ScaleX="{Binding Path=Scale.X, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ModelVisual3D}}} instead of ScaleX="{Binding Scale.X, ElementName=Model} ScaleX="{Binding Path=Scale.X, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ModelVisual3D}}} and for the other properties, respectively, then everything works. - Dmitry Anikin
  • Oh, that's another conversation. And what is displayed in the Output window when running this code? Usually errors in the Binding are visible in the log. - VladD
  • It seems to understand what the problem is, where the line x:Name="Model" writes: "It is impossible to register a duplicate Name" Model "in this area". - Dmitry Anikin
  • Hmm, in the code that you gave, only once is the name Model . And if you change the Model to something else? Or maybe you already have the Model property in the OrbitModelVisual3D class? - VladD

0