Skip to content

GuOrg/Gu.Wpf.ToolTips

Repository files navigation

Gu.Wpf.ToolTips

License NuGet Build status Build Status

Helpers for tool tips.

TouchToolTipService

Tool tips for touch users. Setting TouchToolTipService.Enabled="True" on an element draws an OverlayAdorner over the element with an icon indicating that there is touch info. Tapping opens/closes the tool tip.

Simple sample:

<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:toolTips="http://Gu.com/ToolTips"
        Title="DemoWindow"
        Width="100"
        SizeToContent="Height">
    <Window.Resources>
        <Style TargetType="{x:Type Button}">
            <Setter Property="Padding" Value="6" />
            <Setter Property="toolTips:TouchToolTipService.IsEnabled" Value="False" />
            <Setter Property="ToolTipService.ShowOnDisabled" Value="True" />
            <Style.Triggers>
                <Trigger Property="IsEnabled" Value="False">
                    <Setter Property="toolTips:TouchToolTipService.IsEnabled" Value="True" />
                </Trigger>
            </Style.Triggers>
        </Style>

        <Style TargetType="{x:Type TextBlock}">
            <Setter Property="toolTips:TouchToolTipService.IsEnabled" Value="True" />
            <Setter Property="Padding" Value="6" />
        </Style>

        <Style TargetType="{x:Type Label}">
            <Setter Property="toolTips:TouchToolTipService.IsEnabled" Value="True" />
            <Setter Property="Padding" Value="6" />
        </Style>
    </Window.Resources>

    <AdornerDecorator>
        <StackPanel>
            <Button Content="Button"
                IsEnabled="False"
                ToolTip="Button tool tip." />

            <TextBlock Text="TextBlock"
                   ToolTip="TextBlock tool tip." />

            <Label Content="Label"
                   ToolTip="Label tool tip." />
        </StackPanel>

    </AdornerDecorator>
</Window>

Renders:

Animation

OverlayAdorner

The default style for the overlay is:

<Style TargetType="{x:Type local:OverlayAdorner}">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate>
                <Ellipse x:Name="TouchInfoIcon"
                            Height="{Binding RelativeSource={RelativeSource Self},
                                            Path=ActualWidth}"
                            Width="12"
                            Canvas.Top="0"
                            Canvas.Right="0"
                            Margin="0,2,2,0"
                            HorizontalAlignment="Right"
                            VerticalAlignment="Top">
                    <Ellipse.Fill>
                        <DrawingBrush>
                            <DrawingBrush.Drawing>
                                <DrawingGroup>
                                    <DrawingGroup.Children>
                                        <GeometryDrawing Brush="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}">
                                            <GeometryDrawing.Geometry>
                                                <EllipseGeometry Center="50,50"
                                                                    RadiusX="50"
                                                                    RadiusY="50" />
                                            </GeometryDrawing.Geometry>
                                        </GeometryDrawing>

                                        <GeometryDrawing Brush="White">
                                            <GeometryDrawing.Geometry>
                                                <GeometryGroup>
                                                    <RectangleGeometry Rect="43,15,14,15" />
                                                    <RectangleGeometry Rect="43,36,14,50" />
                                                </GeometryGroup>
                                            </GeometryDrawing.Geometry>
                                        </GeometryDrawing>
                                    </DrawingGroup.Children>
                                </DrawingGroup>
                            </DrawingBrush.Drawing>
                        </DrawingBrush>
                    </Ellipse.Fill>
                </Ellipse>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages