如何修改Avalon 2.0启动布局WPF

时间:2017-05-30 13:42:18

标签: wpf avalondock

我已经下载了avalon 2.0,并且在加载时工具面板从右侧开始,文件面板从左侧开始。

我正在尝试让工具面板在加载时停靠在左侧,即使我删除了与FileViewModel相关的所有内容,左侧加载了一个空白面板保留在左侧。

下图显示了当前窗口的加载方式: Rightpanel

我希望左侧的工具面板加载如下:(我通过在运行时拖动工具窗格来实现此目的。Would like to load the app like this.

在我的WPF中我只能看到一个LayoutAnchorablePane,所以我不明白为什么屏幕被分成两部分?

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="3"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>
    <Menu Grid.Row="0">
        <MenuItem Header="File">
            <MenuItem Header="New" Command="{Binding NewCommand}"/>
            <MenuItem Header="Open" Command="{Binding OpenCommand}"/>
            <Separator/>
            <MenuItem Header="Save" Command="{Binding ActiveDocument.SaveCommand}"/>
            <MenuItem Header="Save As..." Command="{Binding ActiveDocument.SaveAsCommand}"/>
            <Separator/>
            <MenuItem Header="Close" Command="{Binding ActiveDocument.CloseCommand}"/>
        </MenuItem>
        <MenuItem Header="Tools">
            <MenuItem Header="{Binding FileStats.Title, Mode=TwoWay}" IsChecked="{Binding FileStats.IsVisible, Mode=TwoWay}" IsCheckable="True"/>
            <MenuItem Header="{Binding Exported.Title, Mode=TwoWay}" IsChecked="{Binding Exported.IsVisible, Mode=TwoWay}" IsCheckable="True"/>
            <MenuItem Header="{Binding ExportedResult.Title, Mode=TwoWay}" IsChecked="{Binding ExportedResult.IsVisible, Mode=TwoWay}" IsCheckable="True"/>
            <MenuItem Header="{Binding Manifest.Title, Mode=TwoWay}" IsChecked="{Binding Manifest.IsVisible, Mode=TwoWay}" IsCheckable="True"/>
        </MenuItem>
        <MenuItem Header="Layout">
            <MenuItem Header="Load" Command="{Binding LoadLayoutCommand, ElementName=mainWindow}"/>
            <MenuItem Header="Save" Command="{Binding SaveLayoutCommand, ElementName=mainWindow}"/>
            <MenuItem Header="Dump to Console" Click="OnDumpToConsole"/>

        </MenuItem>
    </Menu><!--AnchorablesSource="{Binding Tools}" DocumentsSource="{Binding Files}"-->
    <avalonDock:DockingManager x:Name="dockManager" 
                               AnchorablesSource="{Binding Tools}" 
                               DocumentsSource="{Binding Files}"
                               ActiveContent="{Binding ActiveDocument, Mode=TwoWay, Converter={StaticResource ActiveDocumentConverter}}"
                               Grid.Row="1" >
        <avalonDock:DockingManager.LayoutItemTemplateSelector>
            <local:PanesTemplateSelector>
                <local:PanesTemplateSelector.FileStatsViewTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Vertical">
                            <TextBlock Text="{Binding FileSize}"/>
                            <TextBlock Text="{Binding LastModified}"/>
                            <TextBox Text="test"/>
                        </StackPanel>
                    </DataTemplate>
                </local:PanesTemplateSelector.FileStatsViewTemplate>
            </local:PanesTemplateSelector>
        </avalonDock:DockingManager.LayoutItemTemplateSelector>
        <avalonDock:DockingManager.LayoutItemContainerStyleSelector>
            <local:PanesStyleSelector>
                <local:PanesStyleSelector.ToolStyle>
                    <Style TargetType="{x:Type avalonDock:LayoutAnchorableItem}">
                        <Setter Property="Title" Value="{Binding Model.Title}"/>
                        <Setter Property="IconSource" Value="{Binding Model.IconSource}"/>
                        <Setter Property="Visibility" Value="{Binding Model.IsVisible, Mode=TwoWay, Converter={StaticResource BoolToVisibilityConverter}, ConverterParameter={x:Static Visibility.Hidden}}"/>
                        <Setter Property="ContentId" Value="{Binding Model.ContentId}"/>
                        <Setter Property="IsSelected" Value="{Binding Model.IsSelected, Mode=TwoWay}"/>
                        <Setter Property="IsActive" Value="{Binding Model.IsActive, Mode=TwoWay}"/>
                    </Style>
                </local:PanesStyleSelector.ToolStyle>
            </local:PanesStyleSelector>
        </avalonDock:DockingManager.LayoutItemContainerStyleSelector>
        <avalonDock:DockingManager.LayoutUpdateStrategy>
            <local:LayoutInitializer/>
        </avalonDock:DockingManager.LayoutUpdateStrategy>
        <avalonDock:LayoutRoot>
            <avalonDock:LayoutPanel Orientation="Horizontal" >
                <avalonDock:LayoutAnchorablePane Name="ToolsPane" DockHeight="150" >
                </avalonDock:LayoutAnchorablePane>
                <avalonDock:LayoutDocumentPane />
            </avalonDock:LayoutPanel>
        </avalonDock:LayoutRoot>
    </avalonDock:DockingManager>
</Grid>

1 个答案:

答案 0 :(得分:-1)

这似乎有效,但请注意样本正在保存状态

 <avalonDock:LayoutRoot>
            <avalonDock:LayoutPanel Orientation="Horizontal">
                <avalonDock:LayoutAnchorablePane Name="ToolsPane" DockWidth="100">
                    <avalonDock:LayoutAnchorable>
                        <TextBlock>tototo</TextBlock>
                    </avalonDock:LayoutAnchorable>
                </avalonDock:LayoutAnchorablePane>

                <avalonDock:LayoutDocumentPane/>

            </avalonDock:LayoutPanel>
        </avalonDock:LayoutRoot>
    </avalonDock:DockingManager>