如何使 Resharper 解析 CustomBinding MarkupExtension 的路径 [英] How to make Resharper resolve path for CustomBinding MarkupExtension

查看:21
本文介绍了如何使 Resharper 解析 CustomBinding MarkupExtension 的路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一些扩展的 Binding-Markup-Extension,它的行为就像一个普通的 WPF-Binding,但做了更多的事情(使用不同的默认值,也许添加一些行为等).代码如下所示:

I want to create some extended Binding-Markup-Extension, which behaves just like a normal WPF-Binding but does some things more (use different defaults, maybe add some behavior, etc.). Code looks like this:

public class CustomBindingExtension : Binding
{
  .. some extra properties and maybe overrides ...
}

一切正常,包括 XAML-intellisense,只是我无法让 Resharper 正确解析我的 Binding-Path.即:使用此代码,我可以 [Strg]+单击CurrentText",然后 Resharper 让 vs2010 导航到定义 CurrentText-Property 的代码.

It all works fine including XAML-intellisense, except I just can't make Resharper resolve my Binding-Path correctly. I.e.: using this code I can [Strg]+Click on 'CurrentText' and Resharper lets vs2010 navigate to the code defining the CurrentText-Property.

<UserControl x:Name="uc" ...>
  <TextBox Text="{Binding ViewModel.CurrentText, ElementName=uc}" />
</UserControl>

但是使用 my 绑定,它在运行时正常工作,我只是在悬停CurrentText"时得到一个工具提示,告诉我它是一些MS.Internal.Design.Metadata.ReflectionTypeNode",而不是通过 [Strg]+点击导航.

But using my binding, which works correctly at runtime, I just get a Tooltip when hovering 'CurrentText' telling me it is some 'MS.Internal.Design.Metadata.ReflectionTypeNode', and no navigation via [Strg]+Click.

<UserControl x:Name="uc" ...>
  <TextBox Text="{util:CustomBinding ViewModel.CurrentText, ElementName=uc}" />
</UserControl>

我尝试了以下几件事:

  • 从绑定派生
  • 源自 BindingDecoratorBase
  • 省略我的 CustomBinding 类的扩展"后缀
  • 将标记扩展放在一个单独的程序集中
  • 使用 ConstructorArgumentAttribute
  • 字符串类型的属性和路径属性的类型 PropertyPath
  • 我还查看了原始类 Binding 和 BindingBase,但找不到与我的代码有任何区别的地方.任何想法在这里应该有帮助?或者这只是对 Binding-MarkupExtension 的一种特殊处理,而我自己的 MarkupExtensions 无法获得这种处理方式?

    I also looked at the original classes Binding and BindingBase, but could not find any more difference to my code. Any ideas what should help here? Or is this just a special treatment of the Binding-MarkupExtension which I can in no way get for my own MarkupExtensions?

    16.03.2011 更新:也可能是 Resharper 的错误或缺陷,Jetbrains 正在调查此问题:http://youtrack.jetbrains.net/issue/RSRP-230607

    Update 16.03.2011: Might also be bug or deficiency of Resharper, Jetbrains is investigating the issue: http://youtrack.jetbrains.net/issue/RSRP-230607

    2013 年 12 月 10 日更新:与此同时,该功能似乎正在运行(使用 R# 7.1.3,也许还有更早的版本),我实际上将这种方法与 BindingDecoratorBase 一起使用,我非常喜欢它.也许它只有在您的 MarkupExtension 以绑定"结尾的情况下才有效,但我的确实如此,所以我很高兴.

    Update 10.12.2013: Meanwhile, the feature seems to be working (with R# 7.1.3, maybe also earlier versions), I actually use the approach with the BindingDecoratorBase and I like it a lot. Maybe it only works, if your MarkupExtension ends on 'Binding', but mine does, so I am happy.

    推荐答案

    实际上,在当前版本的 R# 中这是不可能的,不幸的是,它仍然缺少即将发布的 R# 6.1 版本的功能.

    Actually it's not possible in current versions of R# and, unfortunately, still be missing feature of upcoming R# 6.1 release.

    此功能需要大量基础架构更改,但它在我们的列表中,并且肯定会在 R# 7 中实现.看起来像 [CustomBindingMarkup][BindingPath](用于path构造函数参数和Path属性)属性将被引入.

    This feature requires a lot of infrastructure changes, but it's on our list and definitely will be implemented in R# 7. Seems like [CustomBindingMarkup] and [BindingPath] (for path constructor parameter and the Path property) attributes will be introduced.

    对于给您带来的不便,我们深表歉意.

    We really apologize for any inconvenience.

    这篇关于如何使 Resharper 解析 CustomBinding MarkupExtension 的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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