How to make Resharper resolve path for CustomBinding MarkupExtension

寵の児 提交于 2019-12-03 04:09:05

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

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.

You should access your custom Markup-Extension, using the correct namespace:

<UserControl x:Name="uc" ...
xmlns:ext="clr-ns:YourProjectNamespace">
  <TextBox Text="{ext:CustomBinding ViewModel.CurrentText, ElementName=uc}" />
</UserControl>

Here is a nice article about creating custom Markup-Extensions.

One way to fool R# is to name it Binding:

public class Binding : MarkupExtension
{
    public Binding()
    {
    }

    public Binding(string path)
    {
        Path = path;
    }

    public string Path { get; set; }

    public override object ProvideValue(IServiceProvider serviceProvider)
    {
        return 5;
    }
}

Then it works the same as standard binding with R#

<TextBlock Text="{custom:Binding SomeProp}" />
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!