In XAML, <Grid x:Name="MainGrid3">
, Here I want to pass MainGrid3
as a parameter of IValueConverter
. How can I do this?
Asked
Active
Viewed 1.3k times
1 Answers
24
You have ConverterParameter
inside your binding, where you can use another binding with ElementName
of your grid.
<Grid Name="MainGrid3"></Grid>
<TextBlock Text="{Binding SomeBinding, Converter={StaticResource SomeConverter},
ConverterParameter={Binding ElementName=MainGrid3}}"></TextBlock>
Edit: Ok, so apparently I was wrong, you can't use bindings inside ConverterParameter as it is not a dependency property. Working solution would be to use x:Reference
like so:
<Grid Name="MainGrid3"></Grid>
<TextBlock Text="{Binding SomeBinding, Converter={StaticResource SomeConverter},
ConverterParameter={x:Reference Name=MainGrid3}}"></TextBlock>
![](../../users/profiles/971583.webp)
Alan Baljeu
- 2,323
- 4
- 20
- 35
![](../../users/profiles/3859911.webp)
Matas
- 750
- 7
- 15
-
2"where you can use another binding with ElementName". Not true, because the `ConverterParameter` property of a Binding is not a dependency property, and hence can't be bound. See here: http://stackoverflow.com/a/15309844/1136211 – Clemens May 26 '16 at 11:33