Susanna.Rowland
Topic Author
Posts: 5
Joined: 07 Apr 2021, 15:20

TabControl not focusing correctly

23 Apr 2021, 12:28

Hi,
I am attempting to make use of the TabControl for our menu system but while my tests in blend work mostly as expected, when running with Noesis they do not. It seems the TabItems receive focus, but this does not get passed down to the item content as it should.
I have tried using FocusedManager.FocusedElement to force the focus to a specific button on the item, but it seems this is ignored (it does work in blend).
I have also noticed that when I switch tabs using ctrl+tab, the TabItem again keeps the focus and does not pass it to the first child as it should, so I suspect there is an issue in the focus handling of the TabControl in Noesis.
The end result I am looking for is that the tab "buttons" do not hold the focus as we need this to function using a gamepad, where switching tabs is triggered by a key press, but can still be selected with a mouse.
Are there any known workarounds for this issue or am I doing something wrong? I am still new to WPF/XAML.

Here is the test XAML I am using (modified from the Commands sample)
<Window x:Class="Commands.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    FontFamily="./#Aero Matics"
    Foreground="Silver"
    FontSize="24"
    Title="NoesisGUI - Commands">

    <Window.Background>
        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
            <GradientStop Offset="0" Color="#FF184C79"/>
            <GradientStop Offset="0.05" Color="#FF1B5688"/>
            <GradientStop Offset="1" Color="#FF123859"/>
        </LinearGradientBrush>
    </Window.Background>

    <TabControl x:Name="Tabs" FocusManager.FocusedElement="{Binding ElementName=helloBtn}">
        <TabItem x:Name="TabA" Header="A">
            <Viewbox>
                <Border x:Name="myBorder" Width="400" Margin="50"
                Background="#801C1F21" BorderThickness="1" CornerRadius="5" BorderBrush="#40101611" Padding="5"
                HorizontalAlignment="Center" VerticalAlignment="Center">
                    <StackPanel Orientation="Vertical">
                        <StackPanel Orientation="Horizontal" Margin="3">
                            <TextBlock Text="  Input:" Width="90" VerticalAlignment="Center"/>
                            <TextBox Text="{Binding Input, Mode=TwoWay}" MinWidth="280"/>
                        </StackPanel>
                        <StackPanel Orientation="Horizontal" Margin="3">
                            <TextBlock Text="  Param:" Width="90" VerticalAlignment="Center"/>
                            <TextBox x:Name="Param" Text="" MinWidth="280"/>
                        </StackPanel>
                        <Button x:Name="helloBtn" Content="Say Hello" Margin="3" Command="{Binding SayHelloCommand}"
                        CommandParameter="{Binding Text, ElementName=Param}" FontSize="28" />
                        <Button x:Name="helloBtn2" Content="Say Hello" Margin="3" Command="{Binding SayHelloCommand}"
                        CommandParameter="{Binding Text, ElementName=Param}" FontSize="28" />
                        <Viewbox Margin="5" Height="50">
                            <TextBlock Margin="5" Padding="0" TextAlignment="Center" Text="{Binding Output}"
                            FontSize="28" Foreground="White"/>
                        </Viewbox>
                    </StackPanel>
                </Border>
            </Viewbox>
        </TabItem>
        <TabItem Header="B">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition/>
                    <ColumnDefinition/>
                </Grid.ColumnDefinitions>
                <Button Content="TestB" HorizontalAlignment="Center" VerticalAlignment="Center" />
                <Button Content="TestB" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="1" />
            </Grid>
        </TabItem>
    </TabControl>
</Window>

Tags:
 
User avatar
sfernandez
Site Admin
Posts: 2255
Joined: 22 Dec 2011, 19:20

Re: TabControl not focusing correctly

23 Apr 2021, 17:15

If focus is not behaving like in WPF then it is a bug, could you please report it in our bugtracker?
I did some tests and was able to reproduce some inconsistencies between Noesis and WPF, we will fix them as soon as possible.
Sorry for the inconveniences.
 
Susanna.Rowland
Topic Author
Posts: 5
Joined: 07 Apr 2021, 15:20

Re: TabControl not focusing correctly

23 Apr 2021, 18:11

Thank you, I have submitted the following ticket #0001979
 
User avatar
jsantos
Site Admin
Posts: 3139
Joined: 20 Jan 2012, 17:18
Contact:

Re: TabControl not focusing correctly

28 Apr 2021, 11:21

Thanks for this Susanna

Who is online

Users browsing this forum: No registered users and 3 guests