I have come across the situation where I need to do some Binding for ConverterParameter. Something like
1 2 3 4 |
<Button Templat="{StaticResource DeleteButton}" x:Name="BtnDelete" Width="15" Height="15" Click="eleteSignal_Click" Visibility="{Binding Path=Signal,Converter={StaticResource ShowDeleteServiceConverter}}" /> |
I have done lots of research, and I found out that its impossible to do binding for ConverterParameter.
So I came up with the Solution. I created the Converter but inherited from FrameworkElement
public class ShowDeleteServiceConverter : FrameworkElement, IValueConverter
In the converter class, I created a dependency property
1 2 |
public static readonly DependencyProperty SpotsListProperty = DependencyProperty.Register("SpotsList", typeof(IList), typeof(ShowDeleteServiceConverter), null); public IList SpotsList { get {return (IList)GetValue(SpotsListProperty);} set {SetValue(SpotsListProperty, value);} } |
Now, I can do the Binding as usual
1 2 3 4 5 |
<UserControl.Resourses> <Header:ShowDeleteServiceConverter x:Key="ShowDeleteServiceConverter" SpotsList="{Binding ScheduleViewModel.BookingDetailsItems, Source={StaticResource BookingModule}}" </UserControl.Resourses> |
And
1 2 3 4 |
<Button Templat="{StaticResource DeleteButton}" x:Name="BtnDelete" Width="15" Height="15" Click="eleteSignal_Click" Visibility="{Binding Path=Signal,Converter={StaticResource ShowDeleteServiceConverter}}" /> |
It might not be the best solution, but it works for me so far. If you have any idea, feel free to drop me comments.