I want to get size of Grid, but I get NaN.. Here is the xaml file:
<Window x:Class="TestWPFHCI.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:TestWPFHCI"
mc:Ignorable="d"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
Title="MainWindow" Height="700" Width="1024" MinHeight="700" MinWidth="1024">
<Grid Background="#FFEEEEEE">
<ScrollViewer x:Name="scrollOnGrid" Margin="280 55 10 10" HorizontalAlignment="Stretch" VerticalAlignment="Top" HorizontalScrollBarVisibility="Auto">
<!--<Grid Name="MCGrid" Margin="100 100 50 50">
</Grid>-->
<Grid Width="Auto" Margin="10 10 10 10" HorizontalAlignment="Stretch" VerticalAlignment="Top" x:Name="MCGrid">
<!-- <Grid x:Name="MCGrid"/> HorizontalAlignment="Center" VerticalAlignment="Center"/> -->
</Grid>
</ScrollViewer>
</Grid>
</Window>
And here is the code for get grid size, but I always get NaN.. Any idea for solution?
int width = MCGrid.Width;