views:

317

answers:

1

Hi All,

I want to hide the navigation bar in the page created using wpf. i have tried ShowsNavigationUI = false. but still it displaying the control.

Geetha.

+3  A: 

Setting ShowsNavigationUI=false on a Page object ought to do it. There does seem to be a bug, however, that will cause this to fail in at least one sequence of events:

  1. Page is already in NavigationWindow when this is set
  2. Page is navigated away and back again

There may be other scenarios I haven't run into yet that make it fail.

To get this to work totally reliably, what I do is ignore the Page.ShowsNavigationUI property entirely and set it instead on NavigationWindow. This seems to be completely reliable.

Here is how this can be done in your Page constructor:

Dispatcher.BeginInvoke(ApplicationPriority.Render, new Action(() =>
{
  var navWindow = Window.GetWindow(this) as NavigationWindow;
  if(navWindow!=null) navWindow.ShowsNavigationUI = false;
}));

If you do this, remember not to set ShowsNavigationUI on any Page object.

FYI, you can also restyle your NavigationWindow any way you like by changing its ControlTemplate. For example this removes everything but the actual page content:

  <Style TargetType="{x:Type NavigationWindow}">
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type NavigationWindow}">

          <AdornerDecorator>
            <ContentPresenter Name="PART_NavWinCP" 
                              ClipToBounds="true"/>
          </AdornerDecorator>

        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>
Ray Burns