C# - Windows 8 App, using canvas to draw outside of Grid control

less than 1 minute read

Canvas size is always child driven so it will give infinite size for children. Also HorizontalAlignment and VerticalAlignment settings have no effect on a child of a Canvas. However even Canvas size is to zero, it does not affect to draw children.
By using this feature we can allow TextBloc to be displayed outside of Grid as shown the below example.

1
2
3
4
5
<Grid Width="200" Height="100">
    <Canvas>
        <TextBlock Text="Text in a Small Grid" FontSize="144" />
    </Canvas>
</Grid>