zoukankan      html  css  js  c++  java
  • wpf tooltip 样式自定义

     1 <Style BasedOn="{StaticResource {x:Type ToolTip}}" TargetType="ToolTip">
     2 <Setter Property="Template">
     3 <Setter.Value>
     4 <ControlTemplate TargetType="{x:Type ToolTip}">
     5 <Border Width="128"
     6 Height="98"
     7 BorderBrush="#FFDEE7F6"
     8 BorderThickness="1"
     9 CornerRadius="5">
    10 <Border.Background>
    11 <SolidColorBrush Opacity="0.8" Color="White" />
    12 </Border.Background>
    13 <Grid Margin="10,15,0,15">
    14 <Grid.RowDefinitions>
    15 <RowDefinition />
    16 <RowDefinition />
    17 <RowDefinition />
    18 </Grid.RowDefinitions>
    19 <TextBlock VerticalAlignment="Center" Text="{Binding Tag.CityName}" />
    20 <TextBlock Grid.Row="1"
    21 VerticalAlignment="Center"
    22 Text="{Binding Tag.Total, StringFormat=总量:{0} 辆}" />
    23 <TextBlock Grid.Row="2"
    24 VerticalAlignment="Center"
    25 Text="{Binding Tag.TodayCount, StringFormat=今日:{0} 辆}" />
    26 </Grid>
    27 </Border>
    28 </ControlTemplate>
    29 </Setter.Value>
    30 </Setter>
    31 </Style>
    <Path Name="HaiNan"
    Stroke="#FF113FBB"
    StrokeThickness="0.5"
    Tag="xxxxx">
    <Path.ToolTip>
    <ToolTip DataContext="{Binding Path=PlacementTarget, RelativeSource={x:Static RelativeSource.Self}}" />
    </Path.ToolTip>
    
    </Path >

    把需要传入tooltip内的值付到对象的tag对象内,然后tooltip绑定tag作为数据上下文

  • 相关阅读:
    ABP 异常
    Vmware中安装的Ubuntu不能全屏问题解决
    centos7.4 文件权限
    webpack 入门(1)
    webpack(2) 概念
    centos7.4 rpm命令
    centos7.4 which、whereis、locate的使用
    centos7.4 find命令
    centos7.4 lsof用法
    centos7.4 用户和组的管理
  • 原文地址:https://www.cnblogs.com/zsx-blog/p/7494600.html
Copyright © 2011-2022 走看看