• 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作为数据上下文

  • 相关阅读:
    IDEA 代码统计插件使用
    四种遍历ConcurrentHashMap的方式
    Java中多线程并发体系知识点汇总
    程序员高效工具列表
    js数组与字符串的相互转换方法
    ajax使用json数据格式--无效的 JSON 基元
    for和$.each 的记录
    表单提交模型记录
    /Date(1512551901709+0800)/转换
    jsonp的使用记录
  • 原文地址:https://www.cnblogs.com/zsx-blog/p/7494600.html
Copyright © 2020-2023  润新知