lundi 29 juin 2015

Dynamic binding?

May be not a right title for the question but I will try to explain: My TextBox already bound to a property like:

class MyViewModel
    public string TextVal
    {
        get
        {
             if (View != null)
                 return View.Model.TextForValueField;   // other satrts
                 return defaultModel.TextForValueField;// first start
             }
        set
        {
             .....//some setters logic with View.Model.TextForValueField
        } 
    }

When program starts the View is not open so getter binds the value of the field to the value in default model and it is correct, but then , when I open new View my getter correctly returns values from corresponding View.Model.TextForValueField but the field of TextBox on my windows ribbon menu shows the initial value from default model (?) Why?? the xaml for binding is :

<Setter Property="Text" Value="{Binding MyViewModel.YIncr, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>

Perhaps there is a way to call getter once more when a View starts? Something like "Refresh" for ribbons??

Aucun commentaire:

Enregistrer un commentaire