How to make Resharper solution path for CustomBinding MarkupExtension

I want to create an extended Binding-Markup-Extension that behaves like regular WPF-Binding, but does some things more (use different defaults, maybe add some behavior, etc.). The code is as follows:

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

Everything works fine, including XAML-intellisense, except that I just can't get Resharper to correctly resolve my binding. Ie: using this code, I can [Strg] + click "CurrentText", and Resharper allows vs2010 to jump to the code defining CurrentText-Property.

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

But using the my binding, which works correctly at runtime, I just get a hint when "CurrentText" hangs, telling me that it is "MS.Internal.Design.Metadata.ReflectionTypeNode" and there is no navigation on [Strg] + Click.

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

I have tried the following things:

Derive from binding Derive BindingDecoratorBase Leave the suffix 'Extension' for my CustomBinding class add the markup extension to a separate assembly Use constructorArgumentAttribute String property and type PropertyPath for Path-Property

I also looked at the source classes of Binding and BindingBase, but could not find any more differences from my code. Any ideas what should help here? Or is it just a special approach to Binding-MarkupExtension that I can in no way get for my own MarkupExtensions?

Update 16.03.2011: There may also be a bug or shortcoming of Resharper, Jetbrains is investigating the problem: http://youtrack.jetbrains.net/issue/RSRP-230607

Update 10.12.2013: Meanwhile, the function seems to work (with R # 7.1.3, maybe earlier versions), I actually use the approach with BindingDecoratorBase, and I really like it. Maybe it only works if your MarkupExtension ends with "Binding", but mine does, so I'm happy.

+60
visual-studio-2010 wpf xaml resharper markup-extensions
Mar 10 2018-11-11T00:
source share
3 answers

In fact, this is not possible in current versions of R # and, unfortunately, there is still no function for the upcoming release of R # 6.1.

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

We really apologize for any inconvenience.

+4
25 Oct '11 at 10:44
source share
β€” -

You must access your custom extension-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 good article about creating your own extension extensions.

+1
Oct 23 '11 at 12:40
source share

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 just like standard R # binding

 <TextBlock Text="{custom:Binding SomeProp}" /> 
+1
Dec 18 '14 at 22:57
source share



All Articles