<UserControl x:Class="DDCUI.CommDiagnosisWPFCtrl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d" Height="950" Width="300">
<DockPanel LastChildFill="True">
<DataGrid DockPanel.Dock="Top" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" Height="300" AutoGenerateColumns="False" Name="DGComm" CanUserResizeColumns="True" IsReadOnly="True" SelectedCellsChanged="DGComm_SelectedCellsChanged">
<DataGrid.Columns>
<DataGridTextColumn Header="No." Binding="{Binding Number}" Width="0.1*"/>
<DataGridTextColumn Header="Time" Binding="{Binding Time}" Width="0.1*" />
<DataGridTextColumn Header="Protocol" Binding="{Binding Protocol}" Width="0.15*" />
<DataGridTextColumn Header="Source" Binding="{Binding Source}" Width="0.15*" />
<DataGridTextColumn Header="Destination" Binding="{Binding Destination}" Width="0.15*" />
<DataGridTextColumn Header="Data" Binding="{Binding Data}" Width="0.5*" />
</DataGrid.Columns>
</DataGrid>
<TreeView DockPanel.Dock="Top" MinHeight="200" Name="TreeViewDecode"/>
<RichTextBox Name="RtbHexCode"/>
</DockPanel>
</UserControl>
由于某种原因,DataGrid 的 MaxHeight 属性不起作用。也就是说,每当我将一个大表绑定到它时,它总是溢出并隐藏 RichTextBox 和 TreeView(实际上它不应该超过 600 像素并显示垂直滚动条)。
DataGrid 也不显示水平滚动条。
我该如何解决这个问题?
编辑:更新的代码。MaxHeight 属性现在可以工作,但水平滚动条不显示