UWP - 在xaml中的图像上创建数据绑定工具提示

Cor*_*Roy 3 c# xaml tooltip win-universal-app

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

这是重要的片段:

<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>
Run Code Online (Sandbox Code Playgroud)

小智 7

我想知道为什么Tooltip服务代码在图像控件之外你可以尝试内部图像控制并让我知道它是否有效?修改后的代码snipet将是

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