如何将以下 xaml 语句转换为代码?

How do I convert the following xaml statement to code?

类似的问题被问过很多次,但我不能完全解决。我将如何创建以下 xalm 语句的 C# 版本:

        <h:TubeVisual3D x:Name="PipeVisual" Path="{Binding Pipe.Path}" 
                        TextureCoordinates="{Binding Pipe.TextureCoordinates}"
                        Diameter="{Binding ElementName=PipeDiamSlider, Path= Value }" 
                        Material="{Binding Pipe.Material}"
                        BackMaterial="{Binding Pipe.Material}"
                        ThetaDiv="50" IsPathClosed="False"
                        Visible="{Binding ElementName=PipeIsVisibleCheck, Path=IsChecked}"/>

其中“TubeVisual3D”是Helix Toolkit中定义的3D WPF元素,绑定绑定的大部分参数都是“TubeVisual3D”中的依赖属性。

与您的标记等效的是:

HelixToolkit.Wpf.TubeVisual3D pipeVisual = new HelixToolkit.Wpf.TubeVisual3D();
BindingOperations.SetBinding(pipeVisual, HelixToolkit.Wpf.ExtrudedVisual3D.PathProperty, new Binding("Pipe.Path"));
BindingOperations.SetBinding(pipeVisual, HelixToolkit.Wpf.ExtrudedVisual3D.TextureCoordinatesProperty, new Binding("Pipe.TextureCoordinates"));
BindingOperations.SetBinding(pipeVisual, HelixToolkit.Wpf.TubeVisual3D.DiameterProperty, new Binding("Value") { Source = PipeDiamSlider });
BindingOperations.SetBinding(pipeVisual, HelixToolkit.Wpf.MeshElement3D.MaterialProperty, new Binding("Pipe.Material"));
BindingOperations.SetBinding(pipeVisual, HelixToolkit.Wpf.MeshElement3D.BackMaterialProperty, new Binding("Pipe.Material"));
pipeVisual.ThetaDiv = 50;
pipeVisual.IsPathClosed = false;
BindingOperations.SetBinding(pipeVisual, HelixToolkit.Wpf.MeshElement3D.VisibleProperty, new Binding("IsChecked") { Source = PipeIsVisibleCheck });