0

I am writing a WPF application using Infragistics package, which functionality requires opening new windows. One of the windows I open has 5 buttons on it. Buttons become highlighted when I focus on them. When I do not focus on any button, the first button is automatically in focus (it is highlighted like a focused button). I just want all the buttons have same style until I focus one of them.

I just didn't manage to find the solution.

Here is the part of code with the button

<DockPanel>
            <ToolBarTray DockPanel.Dock="Top" IsLocked="True">
                <ToolBar Name="toolBar" Band="1" BandIndex="1" BorderThickness="1" BorderBrush="LightSteelBlue">
                    <Button Name="button1" Click="button1_Click"  BorderBrush="LightSteelBlue" Padding="3" IsEnabled="False" HorizontalContentAlignment="Left">
                        <StackPanel Orientation="Horizontal" >
                            <TextBlock VerticalAlignment="Center">Button 1</TextBlock>
                        </StackPanel>
                    </Button>
<Button HorizontalContentAlignment="Left" Margin="5,0,0,0" Name="button2" Click="button2_Click"  BorderBrush="LightSteelBlue" Padding="5,3,5,3" ToolTip="Load and display debug data shot to check filtering process" 
                            IsEnabled="False">
                        <StackPanel Orientation="Horizontal">
                            <TextBlock VerticalAlignment="Center">Button 2</TextBlock>
                         </StackPanel>
                    </Button>
</ToolBar>
</ToolTray>
</DockPanel>

Now when I do not focus the mouse on any button, the button1 looks like it is focused. I want to look it as a button2.

Hichem BOUSSETTA
  • 1,791
  • 1
  • 21
  • 27
Ruzaki
  • 11
  • 2
  • You can try to set `Focusable="False"` and change it later (after shown?). [Removing focus](https://stackoverflow.com/q/2914495/1997232) is not hard either. – Sinatr May 22 '19 at 11:12
  • I have just tried, but it didn't work. I think there might be a property or a method that sets default focus object or something like that but I can not find any information about it. – Ruzaki May 22 '19 at 11:26
  • Have you tried using [FocusManager](https://learn.microsoft.com/en-us/dotnet/framework/wpf/advanced/focus-overview) instead? – XAMlMAX May 22 '19 at 12:30
  • @XAMIMAX, I have just read about it. Could you specify in which exact element should I use it? – Ruzaki May 22 '19 at 13:44
  • Have you tried `Keyboard.ClearFocus();` ? Execute it when the window has loaded. – Pavlin Marinov Jul 16 '19 at 07:13

0 Answers0