Reputation: 29683
Ok, I have got into below way after following these 2 posts [Post 1
, Post 2
] regarding the question. But this issue is blowing my heads out even after following right ways of implemeting.
So here is my converter which is added in ViewModels
directory of project:
public class ChangePasswordConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
return ....
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
Now below is my HomeWindow.xaml
<Controls:MetroWindow x:Class="KEOffice.Views.HomeWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
xmlns:v="clr-namespace:KEOffice.Views"
xmlns:vm="clr-namespace:KEOffice.ViewModels"
xmlns:prism="http://prismlibrary.com/"
prism:ViewModelLocator.AutoWireViewModel="True">
<Window.Resources>
<vm:ChangePasswordConverter x:Key="ChangePasswordConverter" />
</Window.Resources>
<!--But when I try to do this-->
<Button Command="{Binding ChangePassword.UpdatePassword}">
<Button.CommandParameter>
<MultiBinding ConverterParameter="{StaticResource ChangePasswordConverter}">
<Binding Path="OldPass" ElementName="OldPass"/>
<Binding Path="NewPass" ElementName="NewPass"/>
<Binding Path="ConfirmPass" ElementName="ConfirmPass"/>
</MultiBinding>
</Button.CommandParameter>
</Button>
</Controls:MetroWindow>
Even though I have given proper reference to viewmodels
, where converter exists and Specified valid StaticResource
it throws Cannot set multibinding because multivalue converter must be specified
. I have also done rebuild, clean-rebuild etc., but still the same issue. What else I need to take care to make this work properly?
Upvotes: 0
Views: 2355
Reputation: 7726
You don't use ConverterParameter to specify the converter, you use Converter.
Upvotes: 1