How do you apply DataTemplates defined in the Window.Resources to all Infragistics Panes when they are floating?

StackOverflow https://stackoverflow.com/questions/16217123

سؤال

I am using the Infragistics XamDockManager to handle docking and undocking panels within my application. I have a Window defined that uses the DockManager to specify several different panes. I define several DataTemplates in the Window.Resources so that the data can be presented properly when I bind to one of my classes.

Everything works fine when all of the panes are docked in the application; however, when I undock a pane and it is floating, it doesn't work quite so well. If the data was already being viewed, then it is still displayed properly, but if you change the data by adding to a list or selecting a different item, the new information is not rendered according to the DataTemplate. Instead, it is displayed as though I don't have a data template; it just displays the full class name.

The only ways I have found to get the DataTemplates to apply when the panes are undocked are to either specify the data templates in the Resources section for each individual pane, or to specify them in the App.Xaml Resources section so it applies to the entire application. Unfortunately, I do not want the same templates to apply over the entire application, so the latter option doesn't really work. I have placed the DataTemplates into their own ResourceDictionary, so I can just reference that from each Pane, but it still really obnoxious to have to restate the resources I want to use for every place I want to use them. I thought that placing the data templates in the Window.Resources was supposed to apply them to all other XAML defined in that file.

Does anyone know of a way to get around this?

هل كانت مفيدة؟

المحلول

OK, so I have been working with Infragistics support and delving into the depths of their documentation and I found what I was looking for.

Evidently, when a pane is floating routed events will not bubble up to the main window and styles defined in the main window will not apply to elements in a floating pane (this includes data templates).

For the styles and data templates, there are two possible solutions:

  1. As I mentioned in the question, you can place the styles in App.xaml.
  2. You can handle the ToolWindowLoaded to set styles or attach event handlers for the floating pane. In conjunction with ToolWindowLoaded, you can handle the ToolWindowUnloaded event to remove those event handlers and styles when the pane is no longer floating.
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top