Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

ilist validation wpf mvvm

class MainWindowViewModel : INotifyPropertyChanged
{
    public ICommand SaveItem
    {
        get { return new SimpleCommand(SaveItemExecute, CanSaveItem); }
    }

    public void SaveItemExecute()
    {
        //save
    }

    private bool CanSaveItem()
    {
        return IsValid;
    }

    //I set up here a breakpoint and it returns the correct value just once.
    //The application looked up on CanSaveItem all the time and except the first time, it returns wrong value
    private bool _isValid;
    public bool IsValid
    {
        get { return _isValid; }
        set
        {
            _isValid = value;
            OnPropertyChanged("IsValid");
        }
    }

    public string EnteredText { get; set; }

    public event PropertyChangedEventHandler PropertyChanged;

    protected virtual void OnPropertyChanged(string propertyName)
    {
        if (this.PropertyChanged != null)
        {
            this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
    }

}
Comment

PREVIOUS NEXT
Code Example
Csharp :: Handle all AggregateExceptions when using Task.Whenall() async 
Csharp :: how to detected WindowCloseEvent in other window wpf 
Csharp :: ExpandoObject Make Objects Extensible 
Csharp :: Linq join update without creating new 
Csharp :: WixSharp-FirewallException 
Csharp :: c# nuint 
Csharp :: unity make particles stay still 
Csharp :: displaying list in gameobject Unity 
Csharp :: upcasting and downcasting in c# 
Csharp :: .net core get exe path 
Csharp :: unity raycast hit child object 
Csharp :: obs mfplat.dll 
Csharp :: calculator using single readline c# 
Csharp :: wetter warendorf 
Csharp :: Smooth Sentences c# 
Csharp :: .net framework cheat sheet 
Csharp :: prime number in c# 
Csharp :: c# get first word of string 
Csharp :: minimum value int C# 
Csharp :: c# loop example 
Csharp :: c# application exit 
Csharp :: c# declaration definition 
Csharp :: unity sword trail 
Csharp :: syoutube 
Html :: how to use unsplash images in html 
Html :: ion-content background color 
Html :: html input not editable 
Html :: html long text three dots 
Html :: no cache html 
Html :: range in decimals html 
ADD CONTENT
Topic
Content
Source link
Name
6+3 =