Multiline centered text using TextBlockVisual3D?
#2
This is an interesting question.

With a standard TextBlock it is possible to achieve this with setting the TextAlignment to Center.

Currently the TextBlockVisual3D does not support TextAlignment. But because TextBlockVisual3D is highly customizable, you can set that property to the underlying TextBlock with using a derived class:

Code:
   public class CenteredTextBlockVisual3D : TextBlockVisual3D
   {
       // To add some customization to how TextBlock is rendered,
       // you can override the UpdateTextBlock
       protected override void UpdateTextBlock()
       {
           base.UpdateTextBlock();

           textBlock.TextAlignment = TextAlignment.Center;
       }
   }

Then just use the CenteredTextBlockVisual3D instead of the standard TextBlockVisual3D.

In similar way it is also possible to customize the Border and Plane's MeshGeometry3D - see the CustomTextBlockVisual3DSample for more info.


I see that the TextAlignment can be useful for other users also. Therefore I have added it to the TextBlockVisual3D so it will be available in the next version of Ab3d.PowerToys library.
Andrej Benedik
  


Messages In This Thread
RE: Multiline centered text using TextBlockVisual3D? - by abenedik - 03-23-2018, 03:16 PM

Forum Jump:


Users browsing this thread:
1 Guest(s)