如何在 DevExpress LayoutPanel 中调整 WPF 用户控件的大小
How to resize WPF user control inside the DevExpress LayoutPanel
如何自动调整用户控件的大小以适应 DevExpress Dock LayoutPanel 的大小?我尝试了以下方法,但它不起作用。当我通过鼠标调整布局面板大小时,面板内的用户控件应相应地拉伸以适合面板。
在我的家长控制中XAML.....\
<dxdo:DockLayoutManager>
<dxdo:LayoutGroup x:Name="RootGroup" VerticalAlignment="Stretch">
<dxdo:LayoutPanel x:Name="FundMapPanel" Caption="Fund Map" ItemWidth="400" ItemHeight="320">
<cont:FundMapUserControl></cont:FundMapUserControl>
</dxdo:LayoutPanel>
</dxdo:LayoutGroup>
</dxdo:DockLayoutManager>
并且在我的用户控件中 XAML..
<UserControl
. . .
. . .
Width="{Binding ElementName=FundMapPanel, Path=ItemWidth, Mode=TwoWay}"
Height="{Binding ElementName=FundMapPanel, Path=ItemHeight, Mode=TwoWay}"
. . .
. . .
</UserControl>
正确的做法是:
<dxdo:DockLayoutManager>
<dxdo:LayoutGroup x:Name="RootGroup">
<dxdo:LayoutPanel x:Name="FundMapPanel" Caption="Fund Map" ItemWidth="400" ItemHeight="320">
<cont:FundMapUserControl
VerticalAlignment="Stretch"
HorizontalAligment ="Stretch"
/>
</dxdo:LayoutPanel>
</dxdo:LayoutGroup>
</dxdo:DockLayoutManager>
如您所见,根本没有绑定到 ItemHeight/ItemWidth - 内部控件 被拉伸 以填充 LayoutPanel 的全部内容。
请注意,您不能使用 ItemHeight/ItemWidth 属性,因为它们是 System.Windows.GridLength 对象。
如何自动调整用户控件的大小以适应 DevExpress Dock LayoutPanel 的大小?我尝试了以下方法,但它不起作用。当我通过鼠标调整布局面板大小时,面板内的用户控件应相应地拉伸以适合面板。
在我的家长控制中XAML.....\
<dxdo:DockLayoutManager>
<dxdo:LayoutGroup x:Name="RootGroup" VerticalAlignment="Stretch">
<dxdo:LayoutPanel x:Name="FundMapPanel" Caption="Fund Map" ItemWidth="400" ItemHeight="320">
<cont:FundMapUserControl></cont:FundMapUserControl>
</dxdo:LayoutPanel>
</dxdo:LayoutGroup>
</dxdo:DockLayoutManager>
并且在我的用户控件中 XAML..
<UserControl
. . .
. . .
Width="{Binding ElementName=FundMapPanel, Path=ItemWidth, Mode=TwoWay}"
Height="{Binding ElementName=FundMapPanel, Path=ItemHeight, Mode=TwoWay}"
. . .
. . .
</UserControl>
正确的做法是:
<dxdo:DockLayoutManager>
<dxdo:LayoutGroup x:Name="RootGroup">
<dxdo:LayoutPanel x:Name="FundMapPanel" Caption="Fund Map" ItemWidth="400" ItemHeight="320">
<cont:FundMapUserControl
VerticalAlignment="Stretch"
HorizontalAligment ="Stretch"
/>
</dxdo:LayoutPanel>
</dxdo:LayoutGroup>
</dxdo:DockLayoutManager>
如您所见,根本没有绑定到 ItemHeight/ItemWidth - 内部控件 被拉伸 以填充 LayoutPanel 的全部内容。
请注意,您不能使用 ItemHeight/ItemWidth 属性,因为它们是 System.Windows.GridLength 对象。