我有一个包含TreeListControl的TabControl。 我正在寻找TreeListControl将总是占据Tab的整个区域的方式,即使由于应用程序大小更改而导致Tab大小更改等等。我该怎么做? (不幸的是,我没有看到任何等同于WinForms的Dock.Fill)
<dxdo:DockLayoutManager FloatingMode="Desktop" ClosedPanelsBarVisibility="Never">
<dxdo:LayoutGroup Orientation="Horizontal">
<dxdo:LayoutPanel x:Name="Navigation" Caption="Navigation" AllowClose="False" ItemWidth="200">
<dx:DXTabControl>
<dx:DXTabItem Header="Tasks">
<Grid Background="Transparent">
<dxg:TreeListControl AutoGenerateColumns="AddNew" EnableSmartColumnsGeneration="True" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Height="254" Width="151">
<dxg:TreeListControl.View>
<dxg:TreeListView AllowPerPixelScrolling="True" ShowTotalSummary="True" Height="291" Margin="-17,-19,-24.4,-19.2" VerticalAlignment="Bottom" />
</dxg:TreeListControl.View>
</dxg:TreeListControl>
</Grid>
</dx:DXTabItem>
<dx:DXTabItem Header="Blocks">
<Grid Background="Transparent"/>
</dx:DXTabItem>
<dx:DXTabItem Header="Functions"/>
</dx:DXTabControl>
</dxdo:LayoutPanel>
<dxdo:DocumentGroup x:Name="Documents" DestroyOnClosingChildren="False" ClosingBehavior="HideToClosedPanelsCollection"
dxmvvm:UIRegion.Region="{x:Static common:Regions.Documents}">
<dxdo:DocumentGroup.ItemStyle>
<Style TargetType="{x:Type dxdo:LayoutPanel}">
<Setter Property="Caption" Value="{Binding Caption}"/>
<Setter Property="IsActive" Value="{Binding IsActive, Mode=TwoWay}"/>
</Style>
</dxdo:DocumentGroup.ItemStyle>
</dxdo:DocumentGroup>
</dxdo:LayoutGroup>
</dxdo:DockLayoutManager>
我想尝试这些建议,但偶然发现了第74行,第7行的运行时错误。特别是在这个 - - 最后一行之前。不明白为什么......这里是完整的代码(由于某些原因,关闭UserControl标签的最后一行没有显示在这里:
<UserControl
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"
xmlns:common="clr-namespace:PLCProg.Common;assembly=PLCProg.Common"
xmlns:views="clr-namespace:PLCProg.Main.Views"
xmlns:viewModels="clr-namespace:PLCProg.Main.ViewModels"
xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
xmlns:dxb="http://schemas.devexpress.com/winfx/2008/xaml/bars"
xmlns:dxr="http://schemas.devexpress.com/winfx/2008/xaml/ribbon"
xmlns:dxn="http://schemas.devexpress.com/winfx/2008/xaml/navbar"
xmlns:dxdo="http://schemas.devexpress.com/winfx/2008/xaml/docking"
xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid" xmlns:dxdiag="http://schemas.devexpress.com/winfx/2008/xaml/diagram" x:Class="PLCProg.Main.Views.MainView"
mc:Ignorable="d" d:DesignHeight="500" d:DesignWidth="600"
d:DataContext="{dxmvvm:ViewModelSource {x:Type viewModels:MainViewModel}}">
<dxmvvm:Interaction.Behaviors>
<dxmvvm:VisualStateService/>
</dxmvvm:Interaction.Behaviors>
<dxb:BarManager>
<DockPanel>
<dxr:RibbonControl DockPanel.Dock="Top" RibbonStyle="Office2010" ToolbarShowMode="Hide">
<dxr:RibbonDefaultPageCategory>
<dxr:RibbonPage x:Name="ribbonPage_Main" Caption="View">
<dxr:RibbonPageGroup x:Name="ribbonPageGroup_Main">
<dxr:RibbonGalleryBarItem x:Name="ribbonGalleryBarItem_Theme">
<dxmvvm:Interaction.Behaviors>
<dxr:RibbonGalleryItemThemeSelectorBehavior/>
</dxmvvm:Interaction.Behaviors>
</dxr:RibbonGalleryBarItem>
</dxr:RibbonPageGroup>
<dxr:RibbonPageGroup x:Name="My_Group" Caption="My Group">
<dxb:BarButtonItem x:Name="NewProgramBtn" Content="New Program" Glyph="{dx:DXImage Image=Add_16x16.png}" LargeGlyph="{dx:DXImage Image=Add_32x32.png}" />
<dxb:BarButtonItem x:Name="NewTaskBtn" Content="New Task" Glyph="{dx:DXImage Image=AddFile_16x16.png}" LargeGlyph="{dx:DXImage Image=AddItem_32x32.png}" />
</dxr:RibbonPageGroup>
</dxr:RibbonPage>
</dxr:RibbonDefaultPageCategory>
</dxr:RibbonControl>
<dxdo:DockLayoutManager FloatingMode="Desktop" ClosedPanelsBarVisibility="Never">
<dxdo:LayoutGroup Orientation="Horizontal">
<dxdo:LayoutPanel x:Name="Navigation" Caption="Navigation" AllowClose="False" ItemWidth="200">
<dx:DXTabControl>
<dx:DXTabItem Header="Tasks">
<Grid Background="Transparent">
<dxg:TreeListControl AutoGenerateColumns="AddNew" EnableSmartColumnsGeneration="True" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Height="254" Width="151">
<dxg:TreeListControl.View>
<dxg:TreeListView AllowPerPixelScrolling="True" ShowTotalSummary="True" Height="291" Margin="10, 10, 0, 0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
</dxg:TreeListControl.View>
</dxg:TreeListControl>
</Grid>
</dx:DXTabItem>
<dx:DXTabItem Header="Blocks">
<Grid Background="Transparent"/>
</dx:DXTabItem>
<dx:DXTabItem Header="Functions"/>
</dx:DXTabControl>
</dxdo:LayoutPanel>
<dxdo:DocumentGroup x:Name="Documents" DestroyOnClosingChildren="False" ClosingBehavior="HideToClosedPanelsCollection"
dxmvvm:UIRegion.Region="{x:Static common:Regions.Documents}">
<dxdo:DocumentGroup.ItemStyle>
<Style TargetType="{x:Type dxdo:LayoutPanel}">
<Setter Property="Caption" Value="{Binding Caption}"/>
<Setter Property="IsActive" Value="{Binding IsActive, Mode=TwoWay}"/>
</Style>
</dxdo:DocumentGroup.ItemStyle>
<dxdo:DocumentPanel Caption="Document">
<dxdiag:DiagramControl SelectedStencils="BasicShapes, BasicFlowchartShapes"/>
</dxdo:DocumentPanel>
</dxdo:DocumentGroup>
</dxdo:LayoutGroup>
</dxdo:DockLayoutManager>
</DockPanel>
</dxb:BarManager>
答案 0 :(得分:1)
如果你查看这个Xaml:
<TabControl>
<TabItem Header="Tasks">
<Border Background="Blue" />
</TabItem>
</TabControl>
您可以看到TabItem内容将占据整个区域。
在您的情况下,请设置
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
并且不要设置TreeListControl的 Height =“254”和 Width =“151”。
答案 1 :(得分:0)
将对齐属性( HorizontalAlignment 和 VerticalAlignment )更改为Stretch。
<dxg:TreeListControl AutoGenerateColumns="AddNew" EnableSmartColumnsGeneration="True" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="10,10,0,0" VerticalAlignment="Top" Height="254" Width="151">