jvervoorn wrote:
 | Rossj wrote: I got my menus hooked up to my concrete Document sub-classes via an AppController with virtually NO CODE.... )
|
I think it would be great if you gave more detail.
Basically my Save menu item looks like this..
MenuItem miFileSave = new MenuItem();
miFileSave.Header = "_Save";
miFileSave.SetBinding( MenuItem.IsEnabledProperty, "NeedsSave" );
miFileSave.DataContext = myDocumentControllerInstance;
And now in the NeedsSave property of my DocumentController I just need to use INotifyPropertyChanged's PropertyChanged event in the set{}.
Technically this should be in the Model not the Controller, but I haven't had the chance to move it yet.End result is that the Save menu item is enabled or disabled according to my controller/model's internal state.
I can obviously do this with "Save As", "Close" etc.
On top of all of this, I can also use CommandBindings to assign methods for common commands (like Paste, Cut etc) and have it check whether it is valid before hand by calling my provided CanExecute event handler.
I still have issues with WPF (like given Microsoft's opportunity to provide base functionality IN THE FRAMEWORK for things like Document models - Open/Save/Save As etc ) why it wasn't built in, in a similar fashion to the way NSDocument works in Cocoa which saves tons of time re-writing the same type of code each time I take a new job. MVC in the box might have been nice. And the compositing engine .. more internal info and hooks into that neyond Composition Target.Rendering would have been *fantastic* and saved me a lot of pain.
Our player is shipping and running WPF now*, with a few unavoidable caveats (i.e. I would need hooks into the compositing engine) such as the ActiveX naff-ness and the problem with MediaElement (why *exactly* can't I get at, or provide my own FilterGraph?). I am just in the process of moving the second version of the authoring tool to WPF as well, hence the Document work.
* I'd be interested in knowing what the most widespread WPF apps are currently, this'll be on lots and lots of big displays by the end of this year (and potentially in some very public UK places).