I cant' figure out how to reference the current instance object defined by the XAML file in the XAML file.
我无法弄清楚如何引用XAML文件中XAML文件定义的当前实例对象。
I have a converter that I want to send in the current instance as the 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 object.
在此代码中,它将转换为字符串,而不是对当前实例对象的引用。
Thanks
谢谢
John
约翰
3 个解决方案
#1
4
Technically, the ConverterParameter is not a DependencyProperty, so you can't bind to it. It would be nice to do a ConverterParameter={Binding ElementName=this}, but you can't bind to a non-dependency property.
从技术上讲,ConverterParameter不是DependencyProperty,因此您无法绑定它。做一个ConverterParameter = {Binding ElementName = this}会很好,但你不能绑定到非依赖属性。
But, someone figure it out how to do it here. This is however a bit complicated.
但是,有人在这里弄清楚如何做到这一点。然而,这有点复杂。
#2
3
According to the Data Binding Overview, you can use the "/" to indicate the current item. You can then navigate up and down the tree as needs be using the following type syntaxes:
根据数据绑定概述,您可以使用“/”来指示当前项目。然后,您可以根据需要使用以下类型语法在树中上下导航:
<Button Content="{Binding }" />
<Button Content="{Binding Path=/}" />
<Button Content="{Binding Path=/Description}" />
#3
0
Have you tried using the RelativeSource
markup extension? You can use Self
there.
您是否尝试过使用RelativeSource标记扩展?你可以在那里使用Self。
#1
4
Technically, the ConverterParameter is not a DependencyProperty, so you can't bind to it. It would be nice to do a ConverterParameter={Binding ElementName=this}, but you can't bind to a non-dependency property.
从技术上讲,ConverterParameter不是DependencyProperty,因此您无法绑定它。做一个ConverterParameter = {Binding ElementName = this}会很好,但你不能绑定到非依赖属性。
But, someone figure it out how to do it here. This is however a bit complicated.
但是,有人在这里弄清楚如何做到这一点。然而,这有点复杂。
#2
3
According to the Data Binding Overview, you can use the "/" to indicate the current item. You can then navigate up and down the tree as needs be using the following type syntaxes:
根据数据绑定概述,您可以使用“/”来指示当前项目。然后,您可以根据需要使用以下类型语法在树中上下导航:
<Button Content="{Binding }" />
<Button Content="{Binding Path=/}" />
<Button Content="{Binding Path=/Description}" />
#3
0
Have you tried using the RelativeSource
markup extension? You can use Self
there.
您是否尝试过使用RelativeSource标记扩展?你可以在那里使用Self。