Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MonitoredItem that located on base class of subscription viewmodel does not work #281

Open
sans-eng opened this issue Oct 29, 2024 · 0 comments

Comments

@sans-eng
Copy link

sans-eng commented Oct 29, 2024

Expected:
MonitoredItems that located on base class of the subscrition viewmodel can update it's value base on server value or write to it.

Current behavior:
any properties that marked with MonitoredItemAttribute on base class of the viewmodel is not updated with the value from the server also cannot write any value to the server.

Step to reproduce:
Create a ViewModelBase class that derived from SubscriptionBase class then create a property that marked with MonitoredItemAttribute with it's node id including the backing field, the ViewModelBase can be abstract or concrete (it doesn't matter, both not work), also the ViewModelBase can be marked with SubscriptionAttribute or not (also neither work as expected),
then create any viewmodel class that marked with SubscriptionAttribute which derived from ViewModelBase including the properties that marked with MonitoredItemItemAttribute with it's node id and backing field, then bind any view control (e.g. TextBox or NumberBox),
then you can see the control that bind to property which marked with MonitoredItemAttribute located on the base class is not work as expected, but the control that bind to property which marked with MonitoredItemAttribute located on the viewmodel class which derived from the ViewModelBase class is working perfectly.

.Net version: .NET 7
UI framwork: WinUI 3 1.5.240802000

Edit: I think it because in the SubscriptionBase constructor, when collecting properties it only get the DeclaredProperties instead of all properties.

how about change to this:

foreach (var propertyInfo in typeInfo.GetProperties().Where(p => p.GetCustomAttribute<MonitoredItemAttribute>() != null))
{
//The rest of the codes
}

instead of:

foreach (PropertyInfo declaredProperty in typeInfo.DeclaredProperties)
{
//The rest of the codes
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant