© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
4 replies
Kippachu

❔ 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:

Data.Email.PropertyChanged += (s, e) => OnPreviewContentPropertyChanged($"Data.Email.{e.PropertyName}");
Data.Email.ErrorsChanged += (s, e) => OnPreviewContentErrorChanged($"Data.Email.{e.PropertyName}", e.PropertyName);
Data.Email.PropertyChanged += (s, e) => OnPreviewContentPropertyChanged($"Data.Email.{e.PropertyName}");
Data.Email.ErrorsChanged += (s, e) => OnPreviewContentErrorChanged($"Data.Email.{e.PropertyName}", e.PropertyName);
GDB online Debugger
Online GDB is online ide with compiler and debugger for C/C++. Code, Compiler, Run, Debug Share code nippets.
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Help with WPF app
C#CC# / help
4y ago
❔ need help fixing Bug in WPF app
C#CC# / help
3y ago
Need Help with WPF .NET DataGrid
C#CC# / help
3y ago