我的屏幕上有一個嵌套的數據網格,它不佔用我窗口的整個空間。我設置了數據網格的高度和寬度。我的問題是,當每個屏幕分辨率的數據網格大小是相同的。我如何根據分辨率進行調整? 我可以用MinWidth和MaxWidth以某種方式做到這一點嗎?或類似的東西?如果我使用SizeToContent,它不會最大化窗口。基於屏幕分辨率調整數據網格的大小
這是窗口應該如何看 這是電網與主表XAML的定義:如果你希望你的控件根據調整
<Grid>
<DataGrid Name="tabela"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
IsReadOnly="True"
AlternatingRowBackground="#eeeeee"
ItemsSource="{Binding}"
AutoGenerateColumns="False"
RowDetailsVisibilityChanged="tabela_RowDetailsVisibilityChanged"
SelectionChanged="tabela_SelectionChanged" >
</DataGrid>
</Grid>
:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" MinHeight="30"/>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="209*" />
</Grid.ColumnDefinitions>
<DataGrid Name="tabela" Grid.Row="1" Width="1100" Height="700" HorizontalAlignment="Center" IsReadOnly="True" AlternatingRowBackground="#eeeeee" ScrollViewer.CanContentScroll="True" ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.HorizontalScrollBarVisibility="Auto" ItemsSource="{Binding}" AutoGenerateColumns="False" RowDetailsVisibilityChanged="tabela_RowDetailsVisibilityChanged" SelectionChanged="tabela_SelectionChanged" >