Maxim Kopylov
Maxim Kopylov

Reputation: 23

How to prevent focusing the first menu item of my application on startup?

I use Catel. I need to prevent focusing the first menu item of my application on startup.

This is my window:

<catel:Window x:Class="SpringExpert.Views.MainWindow"
              xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
              xmlns:catel="http://schemas.catelproject.com"
              ShowInTaskbar="True"
              ResizeMode="CanResize"
              Style="{StaticResource WindowStyle}">
  <Grid>
    <Grid.RowDefinitions>
      <RowDefinition Height="Auto" />
      <RowDefinition Height="Auto" />
    </Grid.RowDefinitions>
    <Menu Style="{StaticResource MenuStyle}">
        ...
    </Menu>
  </Grid>
</catel:Window>

On startup of my application the first menu item is focused.

Upvotes: 2

Views: 79

Answers (1)

Geert van Horrik
Geert van Horrik

Reputation: 5724

The DataWindow in Catel automatically focuses the first control for you (since that is the default behavior most people want). However... if you don't want this behavior, you can customize the call to the base in your code-behind like this:

public MainWindow()
  : base(DataWindowMode.Custom, focusFirstControl: false)
{

}

Upvotes: 2

Related Questions