0

I have been writing a project in mvvm where I bind a variable to xaml to show it. The variable is constantly changed in a thread of the model in a for loop. Yet, for some reason the gui doesn't change in value. I have added an if where I check if the value is 62 to see if the value even changes and when I put a break point there the program breaks meaning the problem appears to be in the binding itself. XAML code:

<Label Grid.Row="3" Content="{Binding VM_CurrentTime, Mode = TwoWay}" Grid.Column="1" Margin="-441,7,429,-7"/>

The cs behind it:

public MainWindow()
{
    InitializeComponent();
    vm = new ViewModel(new Model());
    DataContext = vm;
}

now as for the vm:

public int VM_CurrentTime
    {
        get { return _model.PLine; }
        set
        { // here I added an if (currentValue == 62) to check if current value even changes and it does.
            if (currentTime != value)
            {
                _model.PLine = value;
                currentTime = value;
            }
        }
    }
public void updateData(object notifier, string property)
    {
        switch (property)
        {
            case "line":
                VM_CurrentTime = ((Model)notifier).PLine;
                break;
         }
    }

Any help would be greatly appreciated.

ron zamir
  • 23
  • 6

0 Answers0