How to reference the current object in XAML

I cannot figure out how to refer to the current instance of the object defined by the XAML file in the XAML file.

I have a converter that I want to send in the current instance as a parameter object.

{Binding Path=<bindingObject>, Converter={x:Static namespace:Converter.Instance}, ConverterParameter=this} 

In this code, this is converted to a string instead of a reference to the current instance of the object.

thanks

John

+6
wpf xaml
source share
3 answers

Technically, ConverterParameter is not a DependencyProperty, so you cannot get attached to it. It would be nice to do ConverterParameter = {Binding ElementName = this}, but you cannot bind to the non-dependency property.

But someone is figuring out how to do it here . This, however, is a bit complicated.

+4
source share

According to the Data Binding Overview , you can use "/" to indicate the current item. You can then move up and down the tree, as you need to use the following type syntaxes:

 <Button Content="{Binding }" /> <Button Content="{Binding Path=/}" /> <Button Content="{Binding Path=/Description}" /> 
+3
source share

Have you tried using the RelativeSource extension? You can use Self .

0
source share

All Articles