❔ Need help with WPF Prism app
Hello,
Here is the link to the relevant parts of the code: https://www.onlinegdb.com/DAaTMMPEu2
I am developing a WPF app using Prism. The main view is split into two halves, with two separate modules. On the left side, there is a module displaying a data entry form (which can be switched using the navigation drawer). On the right side, I have created a Preview Text Module that displays a FlowDocument loaded in a PreviewTextService.
The idea is that, within my form view models, I load the text I want to display in the PreviewTextService (inside a Dictionary that I convert to a FlowDocument using a converter). Some values are static, while others are linked to property values (properties bound to textboxes inside the form). This way, when I load the form, the default text is displayed in the Preview Text Module. As I input values into the form, the text in the Preview Text Module is automatically updated without regenerating the entire text. Instead, it updates the value linked to the property within the PreviewTextService dictionary.
Additionally, by using the dictionary key, I can perform other manipulations. For example, when a user focuses on a textbox, I can signal to the PreviewTextService that this property is focused, and it will automatically change the background to yellow in the preview text RichTextBox. The same behavior applies for validation errors, changing the foreground to red.
My problem is that I would like to change the way I am registering properties inside the FormsViewModel. Currently, for every property inside FormsViewModel.Data, I have to register their events in the constructor:
Here is the link to the relevant parts of the code: https://www.onlinegdb.com/DAaTMMPEu2
I am developing a WPF app using Prism. The main view is split into two halves, with two separate modules. On the left side, there is a module displaying a data entry form (which can be switched using the navigation drawer). On the right side, I have created a Preview Text Module that displays a FlowDocument loaded in a PreviewTextService.
The idea is that, within my form view models, I load the text I want to display in the PreviewTextService (inside a Dictionary that I convert to a FlowDocument using a converter). Some values are static, while others are linked to property values (properties bound to textboxes inside the form). This way, when I load the form, the default text is displayed in the Preview Text Module. As I input values into the form, the text in the Preview Text Module is automatically updated without regenerating the entire text. Instead, it updates the value linked to the property within the PreviewTextService dictionary.
Additionally, by using the dictionary key, I can perform other manipulations. For example, when a user focuses on a textbox, I can signal to the PreviewTextService that this property is focused, and it will automatically change the background to yellow in the preview text RichTextBox. The same behavior applies for validation errors, changing the foreground to red.
My problem is that I would like to change the way I am registering properties inside the FormsViewModel. Currently, for every property inside FormsViewModel.Data, I have to register their events in the constructor:
GDB online Debugger
Online GDB is online ide with compiler and debugger for C/C++. Code, Compiler, Run, Debug Share code nippets.