AvalonDock现在失去了Alt键装饰 [英] AvalonDock Now Loses Alt Key Adornments

查看:145
本文介绍了AvalonDock现在失去了Alt键装饰的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用AvalonDock(2.0)一段时间了,它是在IDE中管理文档的关键.在上个月左右的时间内,我注意到AkbonDock中的控件不再显示 Alt 键装饰,尽管 Alt 键命令按预期执行.参见下面的图像,菜单中显示了 Alt 键装饰,但没有显示AvalonDock内部的按钮:

I've been using AvalonDock (2.0) for some time now, being key for managing documents in an IDE. In the last month or so, I've noticed that Alt key adornments are no longer showing up for controls within AvalonDock, though the Alt key commands are executing as expected. See the image below where the Alt key adornments are showing up in the menu, but not for the buttons inside AvalonDock:

此问题特别有趣的是,它似乎是由环境设置或条件触发的.

What is particularly interesting about this issue, that it appears to be triggered by an environmental setting or condition.

如该视频(在2:07处)所示, alt关键装饰品正在AvalonDock中用于控件.但是,如果我现在使用与该视频相同的可执行文件,则alt键装饰将无法正常工作.

As demonstrated in this video (at 2:07), the alt key adornments are working for a control within AvalonDock. But, if I now use the very same executable I used in that video, the alt key adornments do not work.

我当前正在使用内部版本2.0.1746,但我也尝试了内部版本2.0.2000(带有Xceed名称空间),并发现了相同的问题.我还尝试使用 Xceed Extended WPF Toolkit 打包的版本,发现问题仍然存在.

I'm currently using build 2.0.1746, but I also tried build 2.0.2000 (with the Xceed namespace) and found the same issue. I also tried the version packaged with the Xceed Extended WPF Toolkit, and found that the issue persists.

我还构建了一个非常简单的测试应用程序,该应用程序加载了几个Item类型的文档,其中Item是具有Name属性的简单类:

I also built a very simple test application which loads a couple of documents of type Item, where Item is a simple class with a Name property:

<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:WpfApplication1"
        xmlns:avalonDock="clr-namespace:Xceed.Wpf.AvalonDock;assembly=Xceed.Wpf.AvalonDock"
        xmlns:avalonDockLayout="clr-namespace:Xceed.Wpf.AvalonDock.Layout;assembly=Xceed.Wpf.AvalonDock"
        xmlns:avalonDockControls="clr-namespace:Xceed.Wpf.AvalonDock.Controls;assembly=Xceed.Wpf.AvalonDock"
        Title="MainWindow" Height="500" Width="500">
    <Window.Resources>
        <ResourceDictionary>
            <DataTemplate DataType="{x:Type local:Item}">
                <StackPanel Orientation="Vertical">
                    <Label Content="Item:" />
                    <TextBox Text="{Binding Name}"/>
                    <Button Content="_ClickMe" />
                </StackPanel>
            </DataTemplate>
        </ResourceDictionary>
    </Window.Resources>
    <Grid>
        <Grid.RowDefinitions>
          <RowDefinition Height="*"></RowDefinition>
          <RowDefinition Height="Auto"></RowDefinition>
        </Grid.RowDefinitions>
        <avalonDock:DockingManager Grid.Row="0"  DocumentsSource="{Binding}">
            <avalonDockLayout:LayoutRoot>
                <avalonDockLayout:LayoutPanel Orientation="Horizontal">
                    <avalonDockLayout:LayoutDocumentPane/>
                </avalonDockLayout:LayoutPanel>
            </avalonDockLayout:LayoutRoot>
        </avalonDock:DockingManager>
        <Button Grid.Row="1" Content="_Test" />
    </Grid>
</Window>

即使使用这个简单的应用程序, Alt 键装饰也会显示在AvalonDock外部的Test按钮上,而不显示在AvalonDock中的控件的ClickMe按钮上.

Even with this simple application, the Alt key adornments show up for the Test button outside of AvalonDock, but not for the ClickMe buttons for the controls within AvalonDock.

我还在AvalonDock Codeplex网站上此处发布了问题,但似乎响应活动很少.我还在此处发布了此问题,位于扩展工具包codeplex网站上.

I also posted the issue here on the AvalonDock codeplex site, but there appears to be very little response activity. I also posted the issue here on the Extended Toolkit codeplex site.

关于如何纠正或解决此问题的任何想法?

Any ideas on how to correct or workaround this issue?

推荐答案

听起来好像将在下一版本的AvalonDock中得到解决.

It sounds as though this will be fixed with the next version of AvalonDock.

与此同时,以下Blend行为是一种解决方法:

In the meantime, the following Blend behavior is a workaround:

public class FixKeyboardCuesBehavior : Behavior<UIElement>
{
    private static readonly DependencyProperty ShowKeyboardCuesProperty;

    static FixKeyboardCuesBehavior()
    {
        Type keyboardNavigation = typeof(KeyboardNavigation);
        var field = keyboardNavigation.GetField("ShowKeyboardCuesProperty", BindingFlags.NonPublic | BindingFlags.Static);

        Debug.Assert(field != null, "field != null");

        ShowKeyboardCuesProperty = (DependencyProperty)field.GetValue(null);
    }

    protected override void OnAttached()
    {
        base.OnAttached();

        Window rootWindow = Window.GetWindow(this.AssociatedObject);
        if (rootWindow == null)
        {
            return;
        }

        BindingOperations.SetBinding(
            this.AssociatedObject,
            ShowKeyboardCuesProperty,
            new Binding("(KeyboardNavigation.ShowKeyboardCues)") { Source = rootWindow });
    }
}

通过将以下内容添加到Xval中的AvalonDock LayoutItemTemplateDataTemplate根元素中,以使用XAML:

Use this from XAML by adding the following to the root element of your DataTemplate for the AvalonDock LayoutItemTemplate:

<i:Interaction.Behaviors
    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity">
    <my:FixKeyboardCuesBehavior />
</i:Interaction.Behaviors>

此变通办法使用WPF的内部实现详细信息来重新引入损坏的AvalonDock逻辑树下的 Alt 行为.因此,我期待在AD本身修复后能够从我的代码中删除它!

This workaround uses internal implementation details of WPF to re-introduce the Alt behaviour below the broken AvalonDock logical tree. So, I'll be looking forward to being able to zap it from my code when AD itself is fixed!

这篇关于AvalonDock现在失去了Alt键装饰的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆