I’m hoping for some insight from someone better experienced than I for creating a window/set of windows for displaying data in WPF. Here is a little overview of my task:
-
I will getting a large amount of binary output from a receiver. This will then be parsed and keyed to the meaning of the particular bit (i.e. word1 bit1 = Receiver Status OK”) for each binary string.
-
The data must then be displayed in a simple window of some sort in the format Receiver Status OK [CheckBox bound to value], or Speed in X direction: [TextBlock bound to value]
The issues are as follows:
-
There are around 60 unique ‘messages’ that need to be displayed when the user needs to look at the incoming data
-
Each message is of a different length of words, each with different meanings and a different number of fields that will have to be displayed.
I would like to know how you would approach this situation. I was thinking of going brute force, one window per message, but that seems very raw. My other thought was making a single standard window with a grid that was the size of the largest message, and then populating it with necessary TextBlocks and such. Then, I just DataBind the keys and values to the fields for each message, and Collapse the unused fields.
Any suggestions would be greatly appreciated. Thank you in advance.
It sounds like you have a bunch of concrete message classes. If this is the case, I would create a new
DataTemplatefor each of the messages in theWindow'sResources. TheDataTemplate'sx:Keyshould be set to the type of the class it is representing. Then, you would set theContentof theWindowto the instance of the message, and it will select the correctDataTemplatefor the type.e.g.
And when you create the
Window: