Dynamically Added PlaneVisual3D Material Disappears
#2
(09-09-2015, 01:26 PM)curimus Wrote: Hello!

When I run following code in my application constructor i got my plane material right, I got Label with white text and black background. While my application runs I add dynamically plane by calling same method again and I get only white text, but background on it is transparent? Could someone tell me what im doing wrong?

Code:
PlaneVisual3D myPlane = new PlaneVisual3D();

Label label = new Label();
label.FontSize = 14;

label.Content = "LocalizedText";
label.Foreground = Brushes.White;
label.Background = Brushes.Black;
                    
VisualBrush brush = new VisualBrush();
brush.Visual = label;        
brush.Stretch = Stretch.Uniform;
      
DiffuseMaterial material = new DiffuseMaterial(brush);
                          
myPlane.Material = material;
myPlane.BackMaterial = material;

myPlane.CenterPosition = new Point3D(0.0, 0.0, 0.0);

myPlane.HeightDirection = new Vector3D(0, 1, 0);
myPlane.Normal = new Vector3D(1, 0, 0);

viewport.Children.Add(myPlane);

Hope you get idea!

Best regards

I Finally sorted it out. I wrapped label inside Border which background was set black and that border was used to made visual brush. Now background works while adding planes dynamically.

Cheers!
  


Messages In This Thread
RE: Dynamically Added PlaneVisual3D Material Disappears - by curimus - 09-10-2015, 02:04 PM

Forum Jump:


Users browsing this thread:
1 Guest(s)