I have an application that it is running in WPF and usings NetAdvantage 12.2. The main window structure, header and such, are in a external dll, i add my content inside of it. I dont have access to the way the tabs are being built. I need, however, to change the Header, the user would like to have the close button right next to the title of the tab. I read this and i created that template and I am trying to set it with a Style. I am pretty new in WPF so I may be doing something wrong, although i have checked with other collegues.
I have this code in a Resource Dictionary, but is not working:
<DataTemplate x:Key="tabItemHeaderWithClose">
<DockPanel x:Name="pnl">
<Button x:Name="closeBtn" DockPanel.Dock="Right"
Visibility="Collapsed"
Margin="3,3,0,3"
Command="{x:Static igWPF:ContentPaneCommands.Close}"
CommandTarget="{Binding Path=Pane,RelativeSource={RelativeSource AncestorType={x:Type igWPF:PaneTabItem}}}"
Style="{DynamicResource {x:Static igWPF:TabGroupPane.DocumentCloseButtonStyleKey}}" />
<TextBlock Text="{Binding}" />
</DockPanel>
<DataTemplate.Triggers>
<Trigger Property="igWPF:XamDockManager.PaneLocation" Value="Document">
<Setter TargetName="closeBtn" Property="Visibility" Value="Visible" />
</Trigger>
</DataTemplate.Triggers>
</DataTemplate>
But it doesnt work
<Style TargetType="igWPF:ContentPane">
<Setter Property="TabHeaderTemplate" Value="{StaticResource tabItemHeaderWithClose}"/>
</Style>
Any help or tips taht you could give me, will be greatly appreciated.
Thanks!
Hi Viviana,
Is that ContentPane style getting applied to your panes? An easy way to check is to add a setter to change the Background color to Red or some other color. If the ContentPanes in the dock manager become red than that means the style is being used. It sounds like the style is not getting used though so it might be where you have the style stored. Where are you keeping that style stored? In the XamDockManager Resources collection?
Hi Rob,
Thanks for your answer. Yes it looks like it is not being used.
It is in a ResourceDictionary at the top level of my application. In other cases works fine. I have some DataTemplates there that work.
I manage to manually search for the Header and then I set the template. That works fine, I just wanted to see if there was something wrong with the template.
It just doesn't inherit the style from WPF. And that is what i really need :(
Thank you!
Do you have any other ContentPane styles in your project that might be overwritting this one? I assume when you say top level of your application you mean the App.Resources? If there is another style somewhere lower in the hierarchy like in the Window.Resources or XamDockManager.Resources it's going to use that instead. That's the only reason I can think of as to why that global style isn't getting applied.
The ThemeManager operates at a lower level than the App level so it will take priority. I'm glad you got it working though. Let me know if you have any further questions on this matter.
Thanks Rob for your help!
I manage to talk with the people that was developing the component I was using, and they changed it so could work with what you said.We didnt know that the ThemeManager had more priority than the App lvl Resources.
In order to make this work you're going to need to move the ContentPane style down into the XamDockManager.Resources collection. This is how you give your style enough priority over the theme style so it gets used. Once it's moved here it will get used and the TabHeaderTemplate that you set in the style will be used for all content panes.
It looks like that is the issue. I've updated my sample and I can now reproduce the issue you're having. Let me look into this a bit and I'll get back to you.
Thanks for your prompt response again.
I don't have any other styles for the header in the application. We are however using the ThemeManager (ThemeManager.CurrentTheme = ThemeManager.ThemeNameIGTheme). Do you think that could be overriding the style I set for the header? If so, is there a way to have more priority than the ThemeManager Style?