This project is read-only.

Zapping a Nasty Bug

I can say I have finally resolved a nasty issue in XHM. The problem was an issue with the Fields from Class window. Until now when that was selected that option from the xaml context menu, and then selected a model class, the window for this option would open, but the fields representing the selected class's properties would not appear.

There were a number of problems with the window that had to be fixed. The missing controls was the result of not binding the class entity to the window properly for C#. The xaml for the window was identical to the xaml code from the previous VB code, but apparently VB does some behind the scenes binding without having to explicitly add a data context. Once I figured out what was needed, controls were created for each property in the class.

However, that was not the end of the problems. The next problem I had to resolve was that the property names did not appear on the controls. That was just a matter of a broken Name property in the PropertyInformation class that's used as the data context for these controls. That was fixed easily once I realized what the problem was.

The hardest problem to fix was getting combo boxes on the controls to bind correctly to a property in its data context. In the original VB code The window's loaded event was utilized to populate the ItemsSource for the ListBox that contains the controls that represent a class's properties. In that event handler the the item objects that represent the properties were initialized and added to a collection. One step in that process was to set the FieldControlType property with the type of control that should used to select a value in the combo box.

The combo boxes were initialized within another event handler, in this case the combo box's loaded event. In C# code this event handler always fired after the window's loaded event. (I suppose it would have to be the same order for VB apps.) For some reason though in C# the code within the combo box's loaded event caused the FieldControlType property for its associated PropertyInformation to be set to the first item in the combobox, whereas we wanted the PropertyInformation's FieldControlType to control what was shown in the combo box.

To make a long story la la la... I refactored those two event handlers to set the combo box's selected item property to correctly represent the data type for its PropertyInformation item. This allowed the combo boxes to initialize correctly.

The changed code right now is only updated in the source. In a few days I will try to upload a new binary package everyone can download and install. I mean to have several other bugs fixed before I do that.

Last edited Jul 26, 2013 at 3:41 AM by gloder, version 4


No comments yet.