Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>(Yes, I know this question is old.)</p> <p>The effectiveness of this solution may vary with the version of Silverlight or the .NET Framework you are using, and I haven't tried it with Silverlight for Windows Phone 7. I wrote a version for stand-alone WPF applications, and I wrote another version that also works in Silverlight.</p> <p>First, the version that works in Silverlight and WPF. Please note that you will need to refactor the code a little bit if you aren't using a Canvas to provide an absolute position for the center of your TextBlock. For example, you may be using a TranslateTransform to position your text.</p> <pre><code>&lt;Canvas&gt; &lt;Canvas.Resources&gt; &lt;ScaleTransform x:Key="transform" ScaleX="-1" ScaleY="-1" /&gt; &lt;/Canvas.Resources&gt; &lt;Grid RenderTransform="{StaticResource transform}" RenderTransformOrigin="-.25 -.25"&gt; &lt;TextBlock RenderTransform="{StaticResource transform}"&gt; Hello! &lt;/TextBlock&gt; &lt;/Grid&gt; &lt;/Canvas&gt; </code></pre> <p>Second, the version that works only in WPF. It doesn't work in Silverlight because it depends on the presence of the Canvas.Right and Canvas.Bottom attached properties. UniformGrid isn't in Silverlight either, but that code could have been replaced by a regular Grid with 2 star-length rows and columns.</p> <pre><code>&lt;Canvas&gt; &lt;UniformGrid Rows="2" Columns="2" DataContext="{Binding ElementName=textBox1}" Width="{Binding Path=ActualWidth}" Height="{Binding Path=ActualHeight}"&gt; &lt;Canvas&gt; &lt;TextBlock Name="textBox1" Canvas.Right="0" Canvas.Bottom="0"&gt; Hello! &lt;/TextBlock&gt; &lt;/Canvas&gt; &lt;/UniformGrid&gt; &lt;/Canvas&gt; </code></pre> <p>By the way, there may be more efficient ways to solve this problem available. I am making no guarantees!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload