Im trying to use multibinding as i have two textboxes to validate for Text.Length.
Here is my code.
<StackPanel HorizontalAlignment="Left" Height="28" Margin="107,238,0,0" VerticalAlignment="Top" Width="104" Orientation="Horizontal" Grid.Column="1"> <Button x:Name="btnAddBenefeciary" Content="Add Beneficiary" HorizontalAlignment="Left" VerticalAlignment="Top" Width="99" RenderTransformOrigin="0.587,0.65" Height="28" Click="btnAddBenefeciary_Click"> <Button.IsEnabled> <MultiBinding Converter="{StaticResource IsEnabledConverter}"> <Binding ElementName="tbFatherName" Path="Text.Length"/> <Binding ElementName="tbFatherName" Path="Text.Length" /> </MultiBinding> </Button.IsEnabled> </Button> </StackPanel> In the Same File i added this line under <Window.Resources>
<local:IsEnabledConverter x:Key="IsEnabledConverter" /> But i am not sure where to put this piece of code so i did put in its own xaml.cs file of which this window belongs.
public class IsEnabledConverter : IMultiValueConverter { public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture) { foreach (var isValid in values) if (isValid as bool? == false) return false; return true; } public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture) { throw new NotImplementedException(); } } Did i needed to create another file or is it fine to use this piece of code in this same file as no one said anything in description of creating new file..
I tried to follow these guide lines.
http://developingfor.net/2009/01/21/multibinding-in-wpf/
Making a Button IsEnabled state depend on two textboxes
So if i have to create new file, how will i reference this to the new file.. Sorry again as i am new to WPF and .NET.
=-=-=-=-=-=-=-=-=
Did changes as per described in answer but getting new errors..
=-=-=-=-=-=-=-
Update 2:
Tried like this..

