WPF根据可见内容停靠最后一个子项

时间:2018-04-09 16:06:07

标签: wpf xaml

所以为了测试目的,我有4个对象。手风琴导航栏和布局控件下的3个布局组。这一小组内部的内容是无关紧要的,我想将左手边的Accordion,然后剩下的三个Layout组中的一个用来填充从Accordion中选择的剩余空间。我将在下面发布代码和图片。

        <dxlc:LayoutControl>
            <dxlc:LayoutGroup VerticalAlignment="Stretch" HorizontalAlignment="Stretch" x:Name="myTag1" Header="LayoutGroup" View="Tabs">
                <dxlc:LayoutGroup Header="General" >
                <StackPanel>
                    <CheckBox Content="Enable Image Processing"></CheckBox>
                    <CheckBox Content="Enable GIS"></CheckBox>
                    <CheckBox Content="Enable Walksort"></CheckBox>
                    <CheckBox Content="Enable eMail Dialog Box"></CheckBox>
                    <CheckBox Content="Enable Work Queue"></CheckBox>
                    <CheckBox Content="Enable Absent Vote Queue"></CheckBox>
                </StackPanel>
            </dxlc:LayoutGroup>
        </dxlc:LayoutGroup>

            <dxlc:LayoutGroup x:Name="myTag2" Header="LayoutGroup" View="Tabs">
                <dxlc:LayoutGroup Header="ToolBars">
                    <StackPanel>
                        <CheckBox Content="Show Version"></CheckBox>
                        <CheckBox Content="Show Group"></CheckBox>
                        <CheckBox Content="Show User"></CheckBox>
                        <CheckBox Content="Show Time"></CheckBox>
                        <CheckBox Content="Show Date"></CheckBox>
                    </StackPanel>
                </dxlc:LayoutGroup>
            </dxlc:LayoutGroup>

            <dxlc:LayoutGroup x:Name="myTag3" Header="LayoutGroup" View="Tabs" IsEnabled="False">
                <dxlc:LayoutGroup Header="Rolling Register">
                    <StackPanel>
                        <CheckBox Content="Display Grid on Register"></CheckBox>
                        <CheckBox Content="Colour Register"></CheckBox>
                        <CheckBox Content="Hide Future Changes on Published Register"></CheckBox>
                        <CheckBox Content="Warn on Forename and Surname Change"></CheckBox>
                    </StackPanel>
                </dxlc:LayoutGroup>
            </dxlc:LayoutGroup>
</dockpanel>

以上是三个布局组,下面将是Accordion,两者都包含在

    <dockpanel>
    <dxnav:OfficeNavigationBar DockPanel.Dock="Left" CustomizationButtonVisibility="Hidden">
        <dxa:AccordionControl>
            <dxa:AccordionItem Header="General" ExpandButtonPosition="Right" GlyphPosition="Left">
                <dxa:AccordionItem Header="General" Cursor="Hand" MouseLeftButtonUp="ChkShow_Checked1" MouseRightButtonUp="ChkShow_Unchecked1"/>
                <dxa:AccordionItem Header="Toolbars" Cursor="Hand" MouseLeftButtonUp="ChkShow_Checked2" MouseRightButtonUp="ChkShow_Unchecked2"/>
                <dxa:AccordionItem Header="Rolling Register" Cursor="Hand" MouseLeftButtonUp="ChkShow_Checked3" MouseRightButtonUp="ChkShow_Unchecked3"/>
                <dxa:AccordionItem Header="Register Screen" Cursor="Hand"/>
                <dxa:AccordionItem Header="Elector List Colours" Cursor="Hand"/>
                <dxa:AccordionItem Header="SMTP Settings" Cursor="Hand"/>
            </dxa:AccordionItem>
            <dxa:AccordionItem Header="Register" ExpandButtonPosition="Right" GlyphPosition="Left" >
                <dxa:AccordionItem Header="Register"/>
                <dxa:AccordionItem Header="Terminology"/>
                <dxa:AccordionItem Header="Orders"/>
                <dxa:AccordionItem Header="Areas"/>
                <dxa:AccordionItem Header="Email Drag'N'Drop"/>
                <dxa:AccordionItem Header="Duplicate-check options"/>
            </dxa:AccordionItem>
            <dxa:AccordionItem Header="WP/Reports" ExpandButtonPosition="Right" GlyphPosition="Left" >
                <dxa:AccordionItem Header="Wordprocessor"/>
                <dxa:AccordionItem Header="Report"/>
                <dxa:AccordionItem Header="Paths"/>
                <dxa:AccordionItem Header="Report Scheduler"/>
            </dxa:AccordionItem>
            <dxa:AccordionItem Header="Image Processing" ExpandButtonPosition="Right" GlyphPosition="Left" >
                <dxa:AccordionItem Header="General"/>
                <dxa:AccordionItem Header="Canvass Image Queue"/>
                <dxa:AccordionItem Header="Absent Votes Image Queue"/>
            </dxa:AccordionItem>
            <dxa:AccordionItem Header="Canvass" ExpandButtonPosition="Right" GlyphPosition="Left" >
                <dxa:AccordionItem Header="General"/>
                <dxa:AccordionItem Header="Exclude the Following"/>
                <dxa:AccordionItem Header="Standard Layout and Output"/>
            </dxa:AccordionItem>
            <dxa:AccordionItem Header="System" ExpandButtonPosition="Right" GlyphPosition="Left" >
                <dxa:AccordionItem Header="Version"/>
                <dxa:AccordionItem Header="Paths"/>
                <dxa:AccordionItem Header="Find"/>
                <dxa:AccordionItem Header="Key"/>
                <dxa:AccordionItem Header="Settings"/>
            </dxa:AccordionItem>
            <dxa:AccordionItem Header="Authority" ExpandButtonPosition="Right" GlyphPosition="Left" >
                <dxa:AccordionItem Header="Authority Details"/>
                <dxa:AccordionItem Header="Registration Officer"/>
            </dxa:AccordionItem>
            <dxa:AccordionItem Header="Dates/Costs" ExpandButtonPosition="Right" GlyphPosition="Left" >
                <dxa:AccordionItem Header="Dates"/>
                <dxa:AccordionItem Header="Register Costs"/>
            </dxa:AccordionItem>
            <dxa:AccordionItem Header="Walksort" ExpandButtonPosition="Right" GlyphPosition="Left" >
                <dxa:AccordionItem Header="Walksort Rates"/>
            </dxa:AccordionItem>
            <dxa:AccordionItem Header="Keys" ExpandButtonPosition="Right" GlyphPosition="Left" >
                <dxa:AccordionItem Header="General Keys"/>
                <dxa:AccordionItem Header="Audit Register Only"/>
                <dxa:AccordionItem Header="Published Register Only"/>
            </dxa:AccordionItem>
            <dxa:AccordionItem Header="Acknowledgements" ExpandButtonPosition="Right" GlyphPosition="Left" >
                <dxa:AccordionItem Header="Automatic Acknowledgements"/>
            </dxa:AccordionItem>
            <dxa:AccordionItem Header="Auto Text" ExpandButtonPosition="Right" GlyphPosition="Left" >
                <dxa:AccordionItem Header="Auto Text Entries"/>
            </dxa:AccordionItem>
            <dxa:AccordionItem Header="Processing" ExpandButtonPosition="Right" GlyphPosition="Left" >
                <dxa:AccordionItem Header="Published to Audit"/>
                <dxa:AccordionItem Header="Audit to Published"/>
                <dxa:AccordionItem Header="Rolling Register Amendment"/>
                <dxa:AccordionItem Header="Rolling Register Month End"/>
                <dxa:AccordionItem Header="Rolling Register Move Elector"/>
                <dxa:AccordionItem Header="NLPG Integration Settings"/>
            </dxa:AccordionItem>
            <dxa:AccordionItem Header="Management" ExpandButtonPosition="Right" GlyphPosition="Left" >
                <dxa:AccordionItem Header="Poll Card"/>
                <dxa:AccordionItem Header="Election Build"/>
                <dxa:AccordionItem Header="Ballot Paper"/>
                <dxa:AccordionItem Header="Absent Vote"/>
                <dxa:AccordionItem Header="General"/>
            </dxa:AccordionItem>
            <dxa:AccordionItem Header="Markers" ExpandButtonPosition="Right" GlyphPosition="Left" >
                <dxa:AccordionItem Header="Markers"/>
            </dxa:AccordionItem>
            <dxa:AccordionItem Header="IER" ExpandButtonPosition="Right" GlyphPosition="Left" >
                <dxa:AccordionItem Header="Communication Details"/>
                <dxa:AccordionItem Header="IER RAG Status Colours"/>
                <dxa:AccordionItem Header="Web Applications"/>
            </dxa:AccordionItem>
            <dxa:AccordionItem Header="DocumentQ" ExpandButtonPosition="Right" GlyphPosition="Left" >
                <dxa:AccordionItem Header="General"/>
                <dxa:AccordionItem Header="Documents"/>
            </dxa:AccordionItem>                
        </dxa:AccordionControl>
    </dxnav:OfficeNavigationBar>

我已经尝试将三个布局组分成单独的布局控制器,虽然这不会填满屏幕,因为我相信没有&#34;最后一个孩子&#34;填补。

The General Tab should take the remaining screen space but because docker is seeing the last child as Layoutcontrol it is sharing the screen space with the other two tabs where the visibility has been set to False

1 个答案:

答案 0 :(得分:0)

简短回答是我应该通过导航页面这样做。