MaterialGroup.Children 屬性

定義

取得或設定 Material 子物件的集合。

C#
public System.Windows.Media.Media3D.MaterialCollection Children { get; set; }

屬性值

MaterialCollection,包含 Material 子物件。

範例

下列範例示範如何將多個材質新增至 MaterialGroup

C#
// The material property of GeometryModel3D specifies the material applied to the 3D object.  
// In this sample the material applied to the 3D object is made up of two materials layered  
// on top of each other - a DiffuseMaterial (gradient brush) with an EmissiveMaterial 
// layered on top (blue SolidColorBrush). The EmmisiveMaterial alters the appearance of  
// the gradient toward blue.

// Create a horizontal linear gradient with four stops.   
LinearGradientBrush myHorizontalGradient = new LinearGradientBrush();
myHorizontalGradient.StartPoint = new Point(0, 0.5);
myHorizontalGradient.EndPoint = new Point(1, 0.5);
myHorizontalGradient.GradientStops.Add(new GradientStop(Colors.Yellow, 0.0));
myHorizontalGradient.GradientStops.Add(new GradientStop(Colors.Red, 0.25));
myHorizontalGradient.GradientStops.Add(new GradientStop(Colors.Blue, 0.75));
myHorizontalGradient.GradientStops.Add(new GradientStop(Colors.LimeGreen, 1.0));

// Define material that will use the gradient.
DiffuseMaterial myDiffuseMaterial = new DiffuseMaterial(myHorizontalGradient);

// Add this gradient to a MaterialGroup.
MaterialGroup myMaterialGroup = new MaterialGroup();
myMaterialGroup.Children.Add(myDiffuseMaterial);

// Define an Emissive Material with a blue brush.
Color c = new Color();
c.ScA = 1;
c.ScB = 255;
c.ScR = 0;
c.ScG = 0;
EmissiveMaterial myEmissiveMaterial = new EmissiveMaterial(new SolidColorBrush(c));

// Add the Emmisive Material to the Material Group.
myMaterialGroup.Children.Add(myEmissiveMaterial);

// Add the composite material to the 3D model.
myGeometryModel.Material = myMaterialGroup;

備註

相依性屬性資訊

識別碼欄位 ChildrenProperty
設定為 的中繼資料屬性 true

適用於

產品 版本
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9