Expose dependency properties on the controls
Currently, the NuGet package consists of two controls:
-
VisualizerControl-- displays the parse tree nodes, token list, and source -
SettingsControl-- UI for choosing the options in the Config
The current steps for using these controls involve:
- creating an instance of both
VisualizerDataandConfigfrom theParseTreeVisualizer.Serializationnamespace - creating one viewmodel (
VisualizerDataViewModelorConfigViewModel) for the corresponding control, using the previous instances. Note that both viewmodels require both instances. - setting the
DataContextof the control to the viewmodel
Consider the native WPF DataGrid. There's a single dependency property which can be set either in code or by databinding; internal viewmodels are created by the DataGrid, and are recreated when the property value changes.
For VisualizerControl, we could expose two dependency properties: VisualizerData and Config. When either property is changed, create a new VisualizerDataViewModel off the new values, and set the control's DataContext to the new viewmodel.
Same for the SettingsControl.
How does the interaction between the two controls work? Presumably, changes to the SettingsControl properties would flow to the VisualizerControl.
Why can't we make use of the dependency properties in the debugging context as well?
Plan:
- [ ] VisualizerControl exposes read/write Source and Config properties. Setting the Source and Config generates the VisualizerData, then the VisualizerDataViewModel. VisualizerDataViewModel is set as the DataContext of the VisualizerControl.
- [ ] VisualizerControl - (Note: the Config may be replaced internally after the VisualizerData is created, but only if it's different from the previous Config. Without this limitation, every change to the source would cause a change to the SettingsControl.Config: update Source -> recreate VisualizerData -> changes the exposed Config -> changes SettingsControl.Config.)
- [ ] VisualizerControl exposes a readonly property VisulizerData, containing the generated VisualizerData.
- [ ] SettingsControl binds to VisualizerControl.VisualizerData (one-way) and VisualizerControl.Config (two-way).
- [ ] SettingsControl exposes VisualizerData and Config properties. Only change exposed Config when config has been modified.
- [ ] SettingsControl When Config or VisualizerData is changed, create new ConfigViewModel and set as DataContext of SettingsControl.
- [ ] Config allow calculating the DiffState even not in a debugging visualizer. Expose this as a separate method, callable by the
Diffmethod.
Usage:
- Bind SettingsControl.Config to VisualizerControl.Config
- Bind SettingsControl.VisualizerData VisualizerCotnrol.VisualizerData
- VisualizerControl.Source and VisualizerControl.Config can be set directly or bound from somewhere else.
Why in debugging visualizer is different?
- We don't have access to the Source.
- Related, but VisualizerData is only generated on the debuggee side.
Problems/Questions:
- An essential requirement is determining when the config has changed.
- Why is ConfigBase not an interface? It only has abstract methods without signatures.