WPF之模仿Visual Studio效果的架構介面

來源:互聯網
上載者:User

方式:使用AvalonDock.dll控制項。


AvalonDock有如下主要元素:

1.DockingManager: DockingManager是AvalonDock中最核心的控制項標籤,容納所有AvalonDock標籤。

2.ResizingPanel: 用於整體介面布局,方向有橫向和縱向。

3.DocumentPane:通常用於包含文字編輯的標籤,也可以包含DockableContents標籤,DocumentPane不能被拖動

4.DocumentContent:包含在DocumentPane裡面,一般用於文本編輯的功能,類似vs2010的代碼編輯框部分。

4.DockablePane:能夠類似vs2010的工具箱面板,能夠吸附在邊框上的效果。

5.DockableContent:包含在DockablePane裡面,下方顯示DockableContent的Title


下面來實現一個類似vs2010的介面,先貼上效果圖:



<Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="24"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="24"/>
        </Grid.RowDefinitions>
        <Menu>
            <MenuItem Header="File">
                <MenuItem Header="New Document" Click="NewDocument_Click"  Name="NewDocument"/>
                <MenuItem Header="Exit"/>
            </MenuItem>
        </Menu>
        <my:DockingManager x:Name="dockManager" Grid.Row="1">
            <my:ResizingPanel Orientation="Vertical">
                <my:ResizingPanel Orientation="Horizontal">
                    <my:DocumentPane Name="DocumentPane1">
                        <my:DocumentContent Title="MyDocument1" Name="MyDoc1">
                            <TextBox Name="tbContents" VerticalScrollBarVisibility="Auto" AcceptsReturn="True" TextWrapping="Wrap"></TextBox>
                        </my:DocumentContent>
                    </my:DocumentPane>
                    <my:DockablePane my:ResizingPanel.ResizeWidth="150">
                        <my:DockableContent x:Name="classesContent" Title="Classes">
                            <TreeView>
                                <TreeViewItem Header="Class1"/>
                                <TreeViewItem Header="Class2"/>
                            </TreeView>
                        </my:DockableContent>
                        <my:DockableContent x:Name="toolsContent" Title="Tools">
                            <ListBox>
                                <ListBoxItem Content="Tool1"></ListBoxItem>
                                <ListBoxItem Content="Tool2"></ListBoxItem>
                                <ListBoxItem Content="Tool3"></ListBoxItem>
                            </ListBox>
                        </my:DockableContent>
                    </my:DockablePane>
                </my:ResizingPanel>
                <my:DockablePane my:ResizingPanel.ResizeHeight="100">
                    <my:DockableContent Title="Errors" x:Name="errorsContent">
                        <ListView>
                            <ListView.View>
                                <GridView>
                                    <GridView.Columns>
                                        <GridViewColumn Header="Error"/>
                                        <GridViewColumn Header="Page"/>

<GridViewColumn Header="File"/>
                                        <GridViewColumn Header="Row"/>
                                    </GridView.Columns>
                                </GridView>
                            </ListView.View>
                        </ListView>
                    </my:DockableContent>
                    <my:DockableContent Title="Output" x:Name="output">
                        <TextBox IsReadOnly="True" AcceptsReturn="True"/>
                    </my:DockableContent>
                </my:DockablePane>
                </my:ResizingPanel>
        </my:DockingManager>
        <StatusBar Grid.Row="2">
            <StatusBarItem Content="AvalonDock 1.3 Sample Project"/>
        </StatusBar>
    </Grid>

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.