WPF NavigationWindow and StatusBar
Is it possible to have a StatusBar in a WPF application that runs a NavigationWindow, other than by including it on each Page hosted by the navigation window?
Yes, overriding NavigationWindow template does the trick:
<NavigationWindow x:Class="Test.NavWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="NavWindow">
<NavigationWindow.Template>
<ControlTemplate TargetType="NavigationWindow">
<DockPanel Background="{TemplateBinding Background}">
<Label Content="StatusBar..."
Background="LightGray"
DockPanel.Dock="Bottom"/>
<ContentPresenter Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"/>
</DockPanel>
</ControlTemplate>
</NavigationWindow.Template>
</NavigationWindow >
It's just demonstration, usually you should perform better tweak of ControlTemplate, thank's god you could find a lot of examples over internet.
精彩评论