Changing Tab ImageSource using DataTrigger

Docking/MDI for WPF Forum

Posted 14 years ago by mark
Version: 10.1.0521
Avatar
Hi,

I am trying to change the tab ImageSource to an hourglass if my ViewModel is in a running state. I thought that I should be able to do something like in my view.xaml:

<dock:DocumentWindow x:Class="Test.View"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:shared="http://schemas.actiprosoftware.com/winfx/xaml/shared"
xmlns:dock="http://schemas.actiprosoftware.com/winfx/xaml/docking"
xmlns:propgrid="http://schemas.actiprosoftware.com/winfx/xaml/propgrid"
xmlns:l="clr-namespace:Test.ViewModels"
Title="{Binding DisplayName, Mode=TwoWay}">

<dock:DocumentWindow.Resources>
<Style TargetType="{x:Type dock:DocumentWindow}" >
<Style.Triggers>
<DataTrigger Binding="{Binding ReportRunningState, Mode=OneWay}"
Value="{x:Static l:ReportState.Running}"
<Setter Property="ImageSource" Value="/Resources/Images/hourglass16.png"/>
</DataTrigger>
<DataTrigger Binding="{Binding ReportRunningState, Mode=OneWay}"
Value="{x:Static l:ReportState.Empty}">
<Setter Property="ImageSource" Value="{x:Null}" />
</DataTrigger>
</Style.Triggers>
</Style>
</dock:DocumentWindow.Resources>

Doing this, the view appears but the tab headers have disappeared. Any ideas what is wrong or how i might acomplish this?

cheers

Comments (4)

Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Mark,

Chances are that your implicit Style is taking precedence over an implicit Style we use to render the document tabs. You can based your Style on ours to correct the issue though. Something like this should work:
xmlns:themes="http://schemas.actiprosoftware.com/winfx/xaml/themes"
...
<Style TargetType="{x:Type dock:DocumentWindow}" BasedOn="{StaticResource {x:Static themes:DockingCommonDictionary.TabbedMdiDocumentStyleKey}}">


Actipro Software Support

Posted 14 years ago by mark
Avatar
perfect, thanks.
Posted 14 years ago by mark
Avatar
Is there an easy way to allow this icon to be a clickable button or do I have to build my own content header template to replicate the whole tab and then add my implementation for Icon?

If its the latter, how can I find the current actipro tab Header template to use as a starting point? (I've seen DockingWindowHEader quickstart which I could possibly use)
Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Mark,

You can't make the image displayed by the tab clickable, as it's presented using an Image control. You could either restyle the document windows, with an updated control template, or use the Header/HeaderTemplate properties.

To do the latter, you would need to set the attached property TabbedMdiHost.IsImageOnTab to false, either on the TabbedMdiHost (for all documents) or on specific windows. Then you'd create a Header/HeaderTemplate that shows a Button on the left, whose content is the associated image, and the Title on the right. As you pointed out, the DockingWindow Header QuickStart shows how to add a button.

You can use our PopupButton from our Shared Library, as it has a "transparency" mode so it would look like an Image until the mouse hovers over it.


Actipro Software Support

The latest build of this product (v24.1.2) was released 1 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.