首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AvalonDock文档绑定

AvalonDock文档绑定
EN

Stack Overflow用户
提问于 2010-06-04 02:33:39
回答 1查看 5.7K关注 0票数 2

我正在使用AvalonDock (link)创建我的应用程序。我有一个工具栏和一个文档窗格(类似于VisualStudio),每个新文档都包含一个文本框。现在,我想在我的工具栏中添加一个撤消按钮,它将撤消放置在所选文档上的文本框中的更改。它与Visual Studio中的完全相同。

我想要完成的是用TabControl和Tabs来回答here。MyCode:

代码语言:javascript
复制
<Window x:Class="_app.MainWindow"
    xmlns:my="clr-namespace:_app"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:ad="clr-namespace:AvalonDock;assembly=AvalonDock"  
    xmlns:osc="clr-namespace:OpenSourceControls;assembly=DockPanelSplitter"
    Title="MainWindow" Height="350" Width="525" Loaded="Window_Loaded"
    DataContext="{Binding RelativeSource={RelativeSource Self}}">

<Grid >
    <Grid.RowDefinitions>
        <RowDefinition Height="24"/>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
        <RowDefinition Height="24"/>
    </Grid.RowDefinitions>

    <!--...Menu And Toolbars -->

    <ToolBarPanel Grid.Row="1" Width="Auto" HorizontalAlignment="Stretch" >
             <ToolBar>
                <Button Command="Undo">Undo</Button>
            </ToolBar>
   </ToolBarPanel>

    <ad:DockingManager x:Name="dockManager" Grid.Row="2">
        <ad:ResizingPanel Orientation="Vertical">
            <ad:ResizingPanel Orientation="Horizontal">
                <ad:DockablePane ad:ResizingPanel.ResizeWidth="150">
                    <ad:DockableContent x:Name="inputContent" Title="Workspace">

                          <!-- some dockable windows -->

                     </ad:DockableContent>
                </ad:DockablePane>

                    <!-- here are added the new Documents-->
                 <ad:DocumentPane Name="mainDocPane" ItemsSource="{Binding ..Don't know..}">
                    <ad:DocumentPane.ItemContainerStyle>
                        <Style TargetType="ad:DocumentContent">
                            <Setter Property="Content" Value="{Binding Content}"/>
                        </Style>
                    </ad:DocumentPane.ItemContainerStyle>
                </ad:DocumentPane>                  
            </ad:ResizingPanel>        
        </ad:ResizingPanel>
    </ad:DockingManager>
</Grid>

我创建了新的文档窗口,如下所示:

代码语言:javascript
复制
    private void NewDocument_Click(object sender, RoutedEventArgs e)
    {
        string title = "Document" + (dockManager.Documents.Count+1).ToString();

        var doc = new Document() { Title = title };
        doc.Show(dockManager);
        doc.Activate();
    }

document类如下所示:

代码语言:javascript
复制
 public partial class Document : AvalonDock.DocumentContent
{
    public Document()
    {
        InitializeComponent();
    }
}

XAML:

代码语言:javascript
复制
<ad:DocumentContent x:Class="_ap.Document"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:osc="clr-namespace:OpenSourceControls;assembly=DockPanelSplitter"
    xmlns:ad="clr-namespace:AvalonDock;assembly=AvalonDock">

<DockPanel>
    <TextBox Name="input" AcceptsReturn="True" />
</DockPanel>

因此,我想在此代码上应用上述链接中的相同机制。

谢谢你的帮助。

EN

回答 1

Stack Overflow用户

发布于 2010-09-08 03:40:44

See the ApplicaionCommands.Undo

一旦您将撤消按钮与.NET FW附带的就地命令捆绑在一起,当TextBox具有焦点时,撤消将发生,而您不必执行任何操作。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/2968750

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档