I have a struct that is defined in a COM library.
In my ViewModel I have created an observable instance of this, and want to bind each member of the struct to different controls in a view.
ConfigStaticDataDetails variable is updated through a delegate in the COM.
Is there a way to catch updates to the members of the struct so that my view reflects the update?
Part of the struct:
public struct ConfigStaticData
{
public string Callsign;
}
My: variable:
private ConfigStaticData _ConfigStaticDataDetails;
public ConfigStaticData ConfigStaticDataDetails
{
get
{
return _ConfigStaticDataDetails;
}
set
{
_ConfigStaticDataDetails = value;
OnPropertyChanged("ConfigStaticDataDetails");
}
}
And in XAML:
<TextBox Name="ConfigStaticDataCallsignLabelTxt"
Margin="0,2,0,2"
Width="230"
Style="{DynamicResource EditableTextBox}"
Text="{Binding Source=ConfigStaticDataDetails, Path=Callsign}" />
I have tried different ways, but this my current code (which doesn’t work).
I think you should replace that struct with a class of your own, only using the struct for portability. Structs should be immutable; as such, there is rarely anything interesting to observe. And due to value semantics, each observer might be seeing a different value (or maybe boxed object). Structs and events don’t mix well…