0
我需要使用wpf应用程序绘制一个3D管道像图像,并将其嵌入到wpf中的自定义控件中..i尝试使用.xaml文件并绘制出像管道一样的管道但我无法得到一个完整大小的正确图像..可以帮助我如何做到..与图形..使用WPF绘制3D管道
我需要使用wpf应用程序绘制一个3D管道像图像,并将其嵌入到wpf中的自定义控件中..i尝试使用.xaml文件并绘制出像管道一样的管道但我无法得到一个完整大小的正确图像..可以帮助我如何做到..与图形..使用WPF绘制3D管道
看看Helix Toolkit。它对wpf 3D有一些很好的控制,包括一个管道示例。
XAML:
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ht="clr-namespace:HelixToolkit.Wpf;assembly=HelixToolkit.Wpf"
Title="MainWindow" Height="350" Width="525">
<Grid>
<ht:HelixViewport3D x:Name="MainViewPort">
<ht:SunLight />
<ht:GridLinesVisual3D/>
</ht:HelixViewport3D>
</Grid>
</Window>
后面的代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using HelixToolkit.Wpf;
using System.Windows.Media.Media3D;
namespace WpfApplication1
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
DataContext = this;
DrawMeshes();
}
private void DrawMeshes()
{
int tubeDiameter = 15;
TubeVisual3D tube1 = new TubeVisual3D();
tube1.Path = new Point3DCollection();
tube1.Path.Add(new Point3D(-15, 0, 0));
tube1.Path.Add(new Point3D(15, 0, 0));
tube1.Diameter = tubeDiameter;
tube1.Fill = Brushes.Red;
tube1.IsPathClosed = false;
MainViewPort.Children.Add(tube1);
}
}
}
什么的.xaml你尝试使用? –