Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

how to disable button in windows in wpf,multibinding,mvvm

$
0
0

hi,

i want to disable a button on window load , that butoon is enabled property is already binded to imultivalueconveter,and that is relaeted to some validation error rule class,now i want that when window load it should disable.plz let me know how to do it

<Button x:Name="btnSave" Height="50" Width="40" Grid.Column="4" Command="{Binding Savefile}"  Grid.Row="1" Style="{StaticResource Tuner4TRONIC_Save}" ><Button.IsEnabled><MultiBinding  Converter="{StaticResource buttonEnabled}"><Binding ElementName="txtDevicename" Path="(Validation.Errors)[0]"></Binding><Binding ElementName="txtGTIN" Path="(Validation.Errors)[0]"></Binding><Binding ElementName="txtBasicCode" Path="(Validation.Errors)[0]"></Binding><Binding ElementName="txthW_versionmajor" Path="(Validation.Errors)[0]"></Binding><Binding ElementName="txtFW_versionmajor" Path="(Validation.Errors)[0]"></Binding><Binding ElementName="txtbank" Path="(Validation.Errors)[0]"></Binding><Binding Path="IsEnableSave" Converter="{StaticResource booltovisibilityConverter}" UpdateSourceTrigger="PropertyChanged" Mode="TwoWay" ></Binding></MultiBinding></Button.IsEnabled></Button>

in last under line code, isenablesave which is defined in path is boolean proerty(get,set) i am trying to bind it.

and my converteretr class is

  public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (!(value is bool))
            {
                throw new InvalidCastException();
            }
            return ((bool)value ? Visibility.Visible : Visibility.Collapsed);
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }

this is i value converter method, i dont know how to achive this.


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>