I have a GroupBox that contains a stackpanel holding a textbox and a datagrid. When I use the textbox to populate the datagrid. Sometimes I need to load the datagrid with values. What I am noticing is that when the groupbox renders when the datagrid has values that the height of the groupbox is maxed out to the size of its parent container. And when I add a value via the textbox the groupbox snaps back to its proper height. Is there something that I am missing? When the datagrid renders it looks like开发者_JAVA百科 all the text in the textcolumns render vertically and then snap into place.
<StackPanel x:Name="LeftDock" Margin="0" VerticalAlignment="Top" MinHeight="480" Width="650" >
<GroupBox x:Name="g_grpBx" Margin="8,8,0,0" Padding="0,10,0,0" MaxWidth="635" MinWidth="612" VerticalAlignment="Top">
<StackPanel x:Name="g_dp" VerticalAlignment="Top">
<local:TextboxControl x:Name="m_txbx" Margin="0" VerticalAlignment="Top" MinWidth="592"/>
<local:GoalDataGrid x:Name="goalDataGrid" Height="Auto" MinHeight="25" MinWidth="592" Margin="0" Padding="0" VerticalAlignment="Top"/>
</StackPanel>
</GroupBox>
</StackPanel>
Setting word wrap to true in the DataGridTextColumn.ElementStyle was the culprit.
精彩评论