Use a textbox as the title of a document window

Docking/MDI for WPF Forum

Posted 7 years ago by Grace
Version: 16.1.0635
Avatar

I am working on updating our ActiPro dlls from 12.1.562 to 2016.1.635. In the old version, we used a text box with images and styles in the header, but the header property is no longer available on document windows. How can I make the title or some other similar property use styles and images?

Comments (2)

Posted 7 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Grace,

We now have custom contextual content features that you can see in the Custom Context Content QuickStart.  That's where you can add UI next to our default tab text display.

Or if you need to fully replace the header, you can do this sort of thing in the new version via the TabbedMdiHost.TabItemContainerStyle property.  Its default value is:

<Style TargetType="docking:AdvancedTabItem">
	<Setter Property="Header" Value="{Binding TabTextResolved}" />
	<Setter Property="HeaderTemplate">
		<Setter.Value>
			<DataTemplate>
				<TextBlock Text="{Binding Converter={StaticResource TitleConverter}}" TextTrimming="None" TextWrapping="NoWrap" VerticalAlignment="Center" />
			</DataTemplate>
		</Setter.Value>
	</Setter>
</Style>

The DataContext passed into the Header of the AdvancedTabItem is the DockingWindow control itself.  Now because it's a UI control and it's already rendered elsewhere in UI, you can't remove the TabTextResolved above to have the Header bind directly to DockingWindow.  That would trigger a logical tree exception. 

That being said, there are a couple tricks you can do if you need to get access to more than one property on DockingWindow.  First would be to bind to some other property instead of TabTextResolved.  For instance you could put a complex object in the DockingWindow.Tag property and bind Header to that instead.  Then update the DataTemplate to interact with properties on that.

However if you need access to the DockingWindow instance itself, then what you can do is in a DockSite.WindowRegistered event handler, execute this code:

e.Window.Tag = new WeakReference(e.Window);

This creates a WeakReference to the DockingWindow insider the DockingWindow.Tag property.  Then in your XAML for TabbedMdiHost, you can do something like this:

<docking:TabbedMdiHost x:Name="tabbedMdiHost">
	<docking:TabbedMdiHost.TabItemContainerStyle>
		<Style TargetType="docking:AdvancedTabItem">
			<Setter Property="Header" Value="{Binding Tag}" />
			<Setter Property="HeaderTemplate">
				<Setter.Value>
					<DataTemplate>
						<TextBox Text="{Binding Target.Title}" TextWrapping="NoWrap" VerticalAlignment="Center" />
					</DataTemplate>
				</Setter.Value>
			</Setter>
		</Style>
	</docking:TabbedMdiHost.TabItemContainerStyle>							
</docking:TabbedMdiHost>

That will use a TextBox to edit the DockingWindow.Title.


Actipro Software Support

Posted 7 years ago by Grace
Avatar

Thank you!

I ended up creating a template for the DockingWindow.TabbedMdiTabContextContentTemplate propety.

The latest build of this product (v24.1.1) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.