Hi
I'm currently creating a Prism based app and I want to be able to show the dirty status of my view model in the tab header as per Visual Studio.
My view model has a bool IsDirty property but I'm not quite sure how to modify the control template to show an asterisk, I guess I'll need a "DirtyToStringConverter" somewhere!
Thanks in advance for any help.
Hello,
I am not sure if you would need to use a converter at all. What you could do is to modify the TabHeaderTemplate of the ContentPane and put a textblock with an asterisk. Then, you can bind the visibility on that textblock based on the IsDirty property of your underlying object, like this :
<DataTemplate x:Key="CPTabHeaderTemplate">
<DockPanel>
<ContentPresenter Content="{Binding Header}" />
<TextBlock Text="*" x:Name="isDirty" Visibility="Collapsed" />
</DockPanel>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding DataContext.Content.IsDirty, RelativeSource={RelativeSource TemplatedParent}}" Value="True">
<Setter Property="Visibility" Value="Visible" TargetName="isDirty" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
I have attached a sample project for your reference.