Help identify the failure to update the property

Scottintexas

Well-known member
Joined
Jun 21, 2018
Messages
47
Location
Texas
Programming Experience
5-10
I added a UI control to display the status (saved or not) of a couple of objects. I used a dictionary so I could have the object name and its status. When the program starts it loads the dictionary and sets the status to "***." Whenever a watched property changes the program saves the instrument and in that method it sets the value to "Saved." I specifically called RaisePropertyChanged in that method but it does not update the UI. When the program starts the instruments and their state are displayed in the <Runs...> I have for them. But they don't update when the property changes. I have stepped through each line and, yes, the value is set, and raise property changed is called and runs. In this example there are two items in the Dictionary. Both item's Keys show up in the UI and the starting values.

C#:
<ListView ItemsSource="{Binding InstSaved}"
            Background="Transparent">
    <ListView.ItemTemplate>
        <DataTemplate>
            <TextBlock Style="{StaticResource TxtBlkStyle}">
                <Run Text="{Binding Key, Mode=OneWay}"/>
                <Run Text="{Binding Value, Mode=OneWay}"/>
            </TextBlock>
        </DataTemplate>
    </ListView.ItemTemplate>
</ListView>
public Dictionary<string, string> InstSaved 
{
    get { return instSaved;}
    set
    {
        instSaved = value;
        RaisePropertyChanged(nameof(InstSaved));
    }
}
public void BuildInstrumentList()
{
    InstrumentList = XFile.GetAllInstruments();
    foreach (Instrument ins in InstrumentList)
    {
        ins.AbortTest += OnAbortTest;
        ins.TestPort += OnTestPort;
        InstSaved.Add(ins.InstrumentName, "***");
        RaisePropertyChanged(nameof(InstSaved));
    }
}

When the SaveFile is called it includes
C#:
                InstSaved[ivm.InstrumentName] = "Saved";
                RaisePropertyChanged(nameof(InstSaved));
An inspection of the dictionary at this point shows the value as Saved.

Thanks.
 
Back
Top Bottom