我無法讓我的xaml以我想要的方式工作。帶有數據網格和擴展器的wpf佈局
我想要的是這個。 我的ItemsControl應該有70的高度。剩下的空間應該填充一個DockPanel。 在DockPanel裏面我有一個GridControl(DevExpress的DataGrid),它應該填充所有的空白空間。網格控件停靠在頂部。在網格控制下面,但仍然插入了DockPanel,我有一個最大高度爲480的擴展器,這應該停靠在底部。
我現在的問題是,我無法讓gridcontrol動態地改變它的高度,以便它填充停靠面板頂部到擴展器之間的所有剩餘空間。
我在做什麼錯了?
<Grid Background="White">
<Grid.RowDefinitions>
<RowDefinition Height="70" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
</Grid.ColumnDefinitions>
<!--#region ItemControl-->
<ItemsControl
Grid.Row="0"
Grid.ColumnSpan="9"
HorizontalAlignment="Stretch"
IsTabStop="False"
ItemsSource="{Binding Path=ToolbarControlViewModel.CommandButtonList}"
Style="{DynamicResource ActionBarPanel}">
<ItemsControl.ItemsPanel>
...
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
...
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<!--#endregion-->
<DockPanel Grid.Row="1">
<!--#region Listview-->
<dxg:GridControl
x:Name="CMGrid"
DockPanel.Dock="Top"
Margin="0,0,0,10"
ItemsSource="{Binding Path=CustomerManagementListViewModel.Customers}"
ScrollViewer.VerticalScrollBarVisibility="Visible">
<dxg:GridControl.Columns>
...
</dxg:GridControl.Columns>
<dxg:GridControl.View>
<dxg:TableView
x:Name="CustomerListView"
AllowBestFit="True"
FocusedRow="{Binding Path=CustomerManagementListViewModel.SelectedCustomer, Mode=TwoWay}"
IsColumnMenuEnabled="False"
NavigationStyle="Row"
ShowGroupPanel="False"
AutoWidth="True"/>
</dxg:GridControl.View>
</dxg:GridControl>
<!--#endregion-->
<!--#region Controls-->
<Expander
MaxHeight="480"
VerticalContentAlignment="Stretch"
DockPanel.Dock="Bottom"
Header="{T:Translate Equipment,
Format=' {0}:'}"
IsExpanded="True"
Style="{StaticResource K2M_Epander_Base}" VerticalAlignment="Bottom">
<Expander.Content>
<Grid>
...
</Grid>
</Expander.Content>
</Expander>
<!--#endregion-->
</DockPanel>
將'DockPanel'全部放在一起並將您的Row = 1應用於GridControl。這是你的罪魁禍首。 –
太簡單了!它的工作原理,非常感謝! :)如果你把它寫成答案,我會相信你。 – merger