UWP - 在 xaml 中的图像上创建数据绑定工具提示 [英] UWP - Creating a data bound tooltip on an image in xaml

查看:20
本文介绍了UWP - 在 xaml 中的图像上创建数据绑定工具提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据驱动的集线器部分,可以很好地填充图像.视图模型包含我想显示为工具提示的文本,但无法完全弄清楚.

I have a data driven hub section that is populating the image just fine. The view model contains text I would like to show as a tooltip, but can't quite figure it out.

这是重要的片段:

<HubSection x:Uid="MyHub" x:Name="MyHubSection" Width="311">
   <HubSection.Header>
      <TextBlock x:Uid="HubMSectionHeader" 
                 Style="{StaticResource MainHubSectionHeaderStyle}" Text="Friends"/>
   </HubSection.Header>
   <DataTemplate>
      <StackPanel>
         <Button x:Name="InviteButton" Content="Send Invite" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Click="InviteButton_Click"/>
         <StackPanel >
            <Grid>
               <GridView ItemsSource="{Binding Friends}"  Background="{ThemeResource HubBackground}" x:Name="FriendGrid" >
                   <GridView.ItemTemplate >
                       <DataTemplate>
                           <Image Source="{Binding ProfilePhotoBitmap, Mode=TwoWay}" Height="100" Opacity="1" Stretch="Uniform" Tapped="Friend_Tapped"/>
                            <ToolTipService.ToolTip>
                                <TextBlock Text="{Binding FullName}"/>
                            </ToolTipService.ToolTip>
                         </DataTemplate>
                     </GridView.ItemTemplate>
                  </GridView>
               </Grid>
            </StackPanel>
         </StackPanel>
      </DataTemplate>
   </HubSection>

推荐答案

我想知道为什么 Tooltip 服务代码在图像控件之外,您可以在图像控件内部尝试并告诉我它是否有效吗?修改后的代码片段将是

I am wondering why the Tooltip service code is outside of the image control could you try inside image control and let me know whether it works or not? modified code snipet will be

<Image Source="{Binding ProfilePhotoBitmap, Mode=TwoWay}" Height="100" Opacity="1" Stretch="Uniform" Tapped="Friend_Tapped">
            <ToolTipService.ToolTip>
                <TextBlock Text="{Binding FullName}"/>
            </ToolTipService.ToolTip>
            </Image>

这篇关于UWP - 在 xaml 中的图像上创建数据绑定工具提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆