Hi,
I have an application that has a mixture of Panels defined in XAML as well as a number that I dynamically add on demand.
My problem is that when I only use the statically defined Panels the application starts and on drag/undock the correct styling is applied to the floating panels. When I dynaamically create panels during startup the styles are no longer used when the panel floats.
I am sure that I am missing some "magic" code here to set the styles (although I wonder why default styles are not automatically used in this case).
My styles define a custom chrome for the floating windows and use UseOsNonClientArea=false to achieve this.
Does anything spring to mind out there?
Regards,
Graham
There should be no difference between defining the panes in xaml or in code. One thing that you should be aware of that will affect the floating panes either way is that the panes that are floating are in a separate WPF Window and therefore they are not part of the logical tree of the xamDockManager and therefore they will not be affected by any implicit styles defined within the xamDockManager or its containing Window. They would only be affected by resources defined in the application's resources or styles from the Theme that is set or things that you explicitly put into the Resources of the ToolWindow (e.g. in the ToolWindowLoaded event).
Having checked I see that your application has referenced the project resources in the App.xaml. For the styles we have copied the xamDockManager styles fully and made changes. That of course means that they are defined as new "default" styles. As you said there seems to be a missing "link" to these styles somewhere - and I am betting that there is a thread building these panels out of sight of the styles somewhere.
I will be looking into your suggestion of loading within the ToolWindowLoaded event. Question is however would it be better loading on a per-style basis or as a resource load bearing in mind that the application is part of a larger corporate defined project with rather lerge resource files and that this is also an event handler? What is your suggestion here Andrew?
Regards
I don't really have many suggestions for you. You can either use a single implicit style that is put into the app's resources to affect the elements within the floating panes (again since these are separate WPF windows) or you can put resources into the ToolWindow's Resources (again using the ToolWindowLoaded event) or you can set the Style of the element in question explicitly. ToolWindowLoaded isn't really called that many times. As to the loading a resource by name you could either do that each time or maybe expose your own custom attached property that maintains a reference to the style in question.
Slight typo in the first sentence "our" instead of "your" :-(
I really do not want to derive from any of your classes as this seems too much overkill for what we want - we wish a style based solution without code-behind overhead - somehting we have partially achieved. I will be looking into the suggestion of loading our styles in the code as you mentioned as a first priority. The "per-style" question is to load the resource by name - this will enable us to see if our styles are available at the point we receive the ToolWindowLoaded event. As this event is fired many times (or at least could be) I am not too happy that the style loading and parsing process of WPF could be kicked off as we are working a real-time hardware data processing environment.
BTW I forgot to mention that we are using the 2010.2 release.
Hope this clears up any questions you had. Please feel free to comment and I look forward to any suggestions that you might have. Additionally, we cannot provide any example code due to the nature of the business area.
Regards,Graham
Intelligence4 said:Having checked I see that your application has referenced the project resources in the App.xaml.
To what application are you referring?
Intelligence4 said:For the styles we have copied the xamDockManager styles fully and made changes. That of course means that they are defined as new "default" styles. As you said there seems to be a missing "link" to these styles somewhere
Intelligence4 said:and I am betting that there is a thread building these panels out of sight of the styles somewhere.
Intelligence4 said: will be looking into your suggestion of loading within the ToolWindowLoaded event. Question is however would it be better loading on a per-style basis or as a resource load bearing in mind that the application is part of a larger corporate defined project with rather lerge resource files and that this is also an event handler? What is your suggestion here Andrew?
For example, one could derive from XamDockManager and override the CreatePaneToolWindow factory method and return a derive PaneToolWindow or manipulate the one being returned. Note this is strictly a factory method so there is no context for what pane(s) will ultimately be using that. If you do derive from XamDockManager (or any other of our elements/controls then please be aware of the implications of that on implicit styles - i.e. that WPF only looks for implicit styles based on the actual class type regardless of the DefaultStyleKey. I talk more about that in my post on theme issues.