Get and set the absolute position of TextBlock by code
Posted: 15 Dec 2018, 12:24
I want to set (or at least get) the position of a TextBlock in Unity. The XAML code looks something like this:
I can set the position using TranslateTransform but the start position is always 0. This makes it very difficult to do absolute positioning if I can't at least get the absolute start position. I suppose I need access to Canvas.Left and Canvas.Top from TextBlock, but the API does not allow that.
I must add that the XAML code is not handwritten so I can't manually modify it, as that is too much work. It is automatically generated by a conversion form Inkscape SVG to XAML using ViewerSVG.
Code: Select all
<TextBlock Name="speed_B" Text="320" FontFamily="#Arial" FontSize="43.2121532069983" Foreground="White" Canvas.Left="16.8453794565401" Canvas.Top="391.239437196062"/>
I must add that the XAML code is not handwritten so I can't manually modify it, as that is too much work. It is automatically generated by a conversion form Inkscape SVG to XAML using ViewerSVG.