I have a WPF window with a grid:
<Grid Name="mainGrid"> <Grid.ColumnDefinitions> <ColumnDefinition Width="20*" /> <ColumnDefinition Width="700*" /> <ColumnDefinition Width="190*" /> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="80" /> <RowDefinition Height="220*" /> <RowDefinition Height="450*" /> <RowDefinition Height="160*" /> <RowDefinition Height="30" /> </Grid.RowDefinitions> </Grid>
In codebehind, I add a stack panel to the 1st column, the second row to mainGrid, but I want the maximum stack panel width to be a column width of 1-50px. I came across accross stkPanel.Width = mainGrid.ColumnDefinitions(1).Width.ToString - 50
, however this will result in an error:
700 * cannot be converted to double
Is there a way to get the actual width of the grid column as it appears on the screen, to use the way I want, or to install an add-on or similar?
Thanks,
Matt
source share