Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
265
XamTab contents in visual tooltip
posted

I am using XamTabControl to develop a screen that looks like Vista's task bar. I want to have the tooltip for each tab to show the small visual of the contents. I am using following XAML but not getting the desired results. Any idea, how do I make it work?

<igWindows:XamTabControl x:Name="xamTab" TabItemCloseButtonVisibility="Visible" DockPanel.Dock="Top" Background="Transparent">
 <igWindows:XamTabControl.ItemContainerStyle>
  <Style TargetType="{x:Type igWindows:TabItemEx }">
   <Setter Property="ToolTip">
    <Setter.Value>
     <ControlTemplate TargetType="{x:Type ToolTip}">
      <StackPanel>
       <Rectangle Width="100" Height="75">
        <Rectangle.Fill>
         <VisualBrush Stretch="Fill"  Visual="{Binding Content}"/>
        </Rectangle.Fill>
       </Rectangle>
      </StackPanel>
     </ControlTemplate>
    </Setter.Value>
   </Setter>
  </Style>
 </igWindows:XamTabControl.ItemContainerStyle>
</igWindows:XamTabControl>

Parents
  • 54937
    Offline posted

    In WPF, you can't set a ToolTip to a ControlTemplate - it won't interpret that as using that template to hydrate an instance of that element. In addition, a ToolTip does not pick up the target element as its datacontext so the binding to Content wouldn't work. You can get further by defining the tooltip in the resources as follows but only the content of the selected tab is actually in the visual tree so until you have actually navigated to the tab items, the elements in the tooltip won't really look right and even then the results of the Visual Brush will be based on the last time the content was measured.

    <ToolTip x:Key="tabToolTip" DataContext="{Binding 
        RelativeSource={RelativeSource Self}, 
        Path=PlacementTarget}">
        <StackPanel>
            <Rectangle Width="100" Height="75">
                <Rectangle.Fill>
                    <VisualBrush 
                        Stretch="Fill" 
                        Visual="{Binding Content}"/>
                </Rectangle.Fill>
            </Rectangle>
        </StackPanel>
    </ToolTip>

     

Reply Children
No Data