AvaloniaUI / Avalonia

Develop Desktop, Embedded, Mobile and WebAssembly apps with C# and XAML. The most popular .NET UI client technology
https://avaloniaui.net
MIT License
25.8k stars 2.23k forks source link

ToolTips are not correctly displayed #5780

Open wisamasd opened 3 years ago

wisamasd commented 3 years ago

If the cursor passes over the StackPanel, then after it is on the panel's object, it displays ToolTip of StackPanel, and only after moving to another object, show tooltip of object

<Window xmlns="https://github.com/avaloniaui"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        x:Class="Controls.Tooltips"
        Title="Tooltips" Height="321" Width="301">
    <StackPanel Margin="5" ToolTip.Tip="StackPanel tooltip">
        <Button ToolTip.Tip="This is my tooltip" >I have a tooltip</Button>
        <Button>
            <ToolTip.Tip>
                <ToolTip Background="#60AA4030" Foreground="White">
                    <StackPanel>
                        <TextBlock Margin="3" >String 1</TextBlock>
                        <TextBlock Margin="3" >String 2</TextBlock>
                    </StackPanel>
                </ToolTip>
            </ToolTip.Tip>
            <Button.Content>I have a fancy tooltip</Button.Content>
        </Button>
        <Button ToolTip.Tip="This is my tooltip"  ToolTip.Placement="Bottom">Placement test</Button>
        <Button Padding="50">Does Nothing</Button>
    </StackPanel>
</Window>

https://user-images.githubusercontent.com/10140116/114829216-79ad6880-9dd3-11eb-9081-f2e9e16af392.mp4

mrj001 commented 10 months ago

I can confirm this is still happening in 11.0.6. I can add two additional (related, I believe) symptoms. I used a Grid to contain the buttons in the StackPanel in my test.

If you move the mouse in from the side over the button with a ToolTip, past the Button, and stopping on the StackPanel (Grid in mine), no ToolTip at all is displayed.

Also, as you move around from the StackPanel (Grid in mine) to the Buttons, you can sometimes get two Tooltips displayed simultaneously. This starts by hovering over the background until the ToolTip shows, then moving over the Child control and getting its ToolTip up.

My similar XAML:

<Window xmlns="https://github.com/avaloniaui"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
      x:Class="AvaloniaToolTip.MainWindow"
      Title="AvaloniaToolTip"
      ToolTip.Tip="Window"
      >
  <DockPanel>
    <StackPanel Orientation="Horizontal" Margin="0,5,0,0"
           HorizontalAlignment="Right"
           DockPanel.Dock="Bottom">
      <StackPanel.Styles>
        <Style Selector="Button">
          <Setter Property="HorizontalAlignment" Value="Stretch" />
          <Setter Property="VerticalAlignment" Value="Stretch" />
          <Setter Property="VerticalContentAlignment" Value="Center" />
          <Setter Property="HorizontalContentAlignment" Value="Center" />
        </Style>
      </StackPanel.Styles>
      <Grid ColumnDefinitions="*,*,*" RowDefinitions="*,*,*" Background="Yellow" 
            Name="MyGrid"
            ToolTip.Tip="Grid"
            >
        <Button Content="Zero" Grid.Row="0" Grid.Column="0" ToolTip.Tip="Zero Button" />
        <Button Content="Hello" Grid.Row="1" Grid.Column="1" ToolTip.Tip="Hello Button" />
        <Button Content="Bye" Grid.Row="2" Grid.Column="2" ToolTip.Tip="Bye Button" />
      </Grid>
    </StackPanel>
  </DockPanel>
</Window>
maxkatz6 commented 6 months ago

Should be fixed in 11.1 nightly builds.