我正在尝试将数据网格添加到主控件宽度设置为拉伸的 UserControl。控件被添加到主面板上的 StackPanel 中,我希望控件的宽度可以拉伸。
我的数据网格设置了宽度,但除非我在用户控件上定义宽度,否则所有列都会缩小到大约 10 像素。
<Expander Header="Issues" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" Margin="4,86,4,4" VerticalAlignment="Stretch" IsExpanded="False">
<Grid Background="#FFE5E5E5" HorizontalAlignment="Stretch" Width="Auto">
<DataGrid x:Name="dg_issues" CanUserResizeRows="False" CanUserReorderColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" CanUserSortColumns="False" CanUserResizeColumns="True" HorizontalAlignment="Stretch" AutoGenerateColumns="False" HeadersVisibility="Column" SelectionMode="Single">
<DataGrid.Columns>
<DataGridTextColumn Header="ID" Binding="{Binding Key}" Width="60"/>
<DataGridTextColumn Header="Status" Binding="{Binding Status}" Width="60"/>
<DataGridTextColumn Header="Summary" Binding="{Binding Summary}" Width="*"/>
<DataGridTextColumn Header="Time Spent" Binding="{Binding TimeSpent}" Width="70"/>
<DataGridTextColumn Header="Remaining" Binding="{Binding Remaining}" Width="70"/>
</DataGrid.Columns>
</DataGrid>
</Grid>
</Expander>
慕盖茨4494581
相关分类