Cannot Apply any style values to DocumentWindow

Docking/MDI for WPF Forum

Posted 8 years ago by sean duggan - bank of america
Avatar
Hi,

I am having trouble apply styles to the DocumentWindow since release 530. prior to 530 I could set the Image via a trigger, but now I cannot even set it, or the title through a Style.

I have included the following code that shows what I am doing. Any help would be appreciated.

Xaml looks like this

<dock:DocumentWindow x:Class="xyzNameSpace.TestReportView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dock="http://schemas.actiprosoftware.com/winfx/xaml/docking"
xmlns:Views="clr-namespace:xyzNameSpace" >

<dock:DocumentWindow.Resources>

<Style TargetType="{x:Type Views:TestReportView}">
<Setter Property="ImageSource" Value="//Images/Left.PNG"></Setter>
<Setter Property="Title" Value="TESTTEST" />
</Style>

</dock:DocumentWindow.Resources>

<Grid>
<TextBox Text="testText" />
</Grid>
</dock:DocumentWindow>


then in c# I create, add and activate the new documentWindow as follows.

var testReportView = new TestReportView();

dockSite.DocumentWindows.Add(testReportView);

testReportViewActivate(true);

If I set the values (eg Title) via code, then they appear, but if I use the Xaml Style as shown above, then nothing works.

Thanks,
Sean.

Comments (1)

Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Sean,

I believe this is the same question asked by a co-worker of yours, but I'll include a summary of the answer here.

In the Docking & MDI topic "Converting from Previous Versions/Converting to 2010.2", the "Changed How Docking Window Styles Are Applied" describes the breaking changed you are running into.

In previous versions, we used implicit Styles to apply the various looks to the DocumentWindows & ToolWindows (i.e. Tabbed MDI, Standard MDI, or a docked ToolWindow). These implicit Styles where defined in the resources of various elements and made it difficult to customize the default Styles.

In this build, we moved to follow a more natural WPF pattern of using the ItemContainerStyle/Selector of the containing element (i.e. TabbedMdiContainer, StandardMdiHost, or ToolWindowContainer) to apply the various looks. This effectively sets the DocumentWindow/ToolWindow Style property, which takes precedence over any implicit Styles. In general, implicit Styles cannot be used for DocumentWindows or ToolWindows because their Style needs to change based on where they are located. Your case is probably the only exception to this rule, but assumes that you will never switch
to using a standard MDI.

So in general, you'd need to set the properties using a Binding and/or custom IValueConverter directly. Alternatively, you could use a custom StyleSelector and assign that to the TabbedMdiContainer.ItemContainerStyleSelector. This is useful if your Style is more complex that the one below. Let me know if you'd like more information on this.


Actipro Software Support

The latest build of this product (v2018.1 build 0675) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.