OT: WPF UserControl's and commands

OT: WPF UserControl's and commands

Old forum URL: forums.lhotka.net/forums/t/6512.aspx


ajj3085 posted on Thursday, February 26, 2009

Hi,

I'm trying to create some Wpf user controls, which are focused at editing a single BO.  I found a way to have a menu (actually a XamRibbon from Infragistics) host a Save button, and using the Load / Unload events of each control I set the RibbonButton's CommandTarget to the apprpriate object.  Save now properly enabled / disables based on the currently viewed UserControl and state of the BO. 

That's fine for standard buttons... but I'd also like some "non-standard" commands.  For example, when editing a part, there should be a button that, when clicked, will open the BOM for that part for editing.  It doesn't seem like a good idea to have all these buttons that may not even be relevent to the currently viewed BO.  Any ideas on how to dynamically create these?  I'd like to not tie my impelementation directly to the Ribbon, because I'll likely use these Wpf controls in my existing WinForms app, and I'll want to use the MergeMenu feature found in WinForms controls.

Any ideas?

Thanks
Andy

rfcdejong replied on Friday, February 27, 2009

Don't u want to use DelegateCommands, simply bind the command to your xaml button and handle it somewhere else. Not hard tied directly to the Ribbon.

In Composite Application Guidance (Prism) they implimented an extended version DelegateCommands which we are using.

http://msdn.microsoft.com/en-us/library/dd458928.aspx

Maybe i don't understand your problem, as it seems as a bit too easy solution ;)

ajj3085 replied on Friday, February 27, 2009

Well I'm not using Prism, so I'm not familiar with DelegateCommands.  I also don't see how the information in that link helps me add / remove buttons or button groups which aren't relevant to the current document.  Could you elaborate a bit more?

rfcdejong replied on Sunday, March 01, 2009

ajj3085:
Well I'm not using Prism, so I'm not familiar with DelegateCommands.  I also don't see how the information in that link helps me add / remove buttons or button groups which aren't relevant to the current document.  Could you elaborate a bit more?


Maybe im spoiled with Prism, saidly u don't use it. But it feels like u are searching for the same functionality a DelegateCommand offers. Anyway like i said i might be misreading your question. Heck, i don't even know what u mean with MergeMenu :)

Dynamically create buttons? I don't see the point in doing that, do u have an own abstraction layer over the control sets in WinForms and WPF?

Like u wrote in the title of this thread, perhaps it's offtopic for this forum. U could ask your question a bit more specific on a WPF forum somewhere, don't ask me which one ;)

channel9?

ajj3085 replied on Monday, March 02, 2009

rfcdejong:
Heck, i don't even know what u mean with MergeMenu :) Dynamically create buttons? I don't see the point in doing that, do u have an own abstraction layer over the control sets in WinForms and WPF?


In WinForms, you can have a MDI Parent window with a Menu, and an MDI Child with a Menu.  If they both share the same key, they will be "merged" so that all the MenuItems that are in the parent appear with all the MenuItems in the child when that child is the active MDI window.

For example, in my main menu on the MDI parent, I have a View toolbar menu.  There's a MenuItem for Navigation Bar which is a checkable menu item.  It's always there.  Also, if you're viewing an invoice in the InvoiceForm MDI child, the're a View Menu that contains a Related Documents.  When that child has the focus, the user can click View and both items display.  When the MDI child is closed, the Related Documents is removed from the menu.  This is all automatic.

In WPF, there's no more MDI, but you can do "tabbed documents," which is similar to visual studio.  In VS 2008, when you have a Code window open, you have the Refactor menu.  Close all windows, and Refactor is removed from the menu bar.  This is the functionaity I'm trying to achive.

rfcdejong:
Like u wrote in the title of this thread, perhaps it's offtopic for this forum. U could ask your question a bit more specific on a WPF forum somewhere, don't ask me which one ;) channel9?


This is true... but I think this issue is probably one others have or will come up against.  Unless everyone here is building Single Document Interface applications.  Smile [:)]  The valid choices in Wpf though seem to be SDI or TDI, as MDI has been frowned upon for some time now, even in WinForms.

Copyright (c) Marimer LLC