Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You can create a UserControl for your header</p> <pre><code>&lt;UserControl DataContext="{Binding RelativeSource={RelativeSource Self}}" x:Class="TabControlHeader.TabItemHeader" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" mc:Ignorable="d" Width="Auto" Height="Auto"&gt; &lt;Grid &gt; &lt;StackPanel&gt; &lt;Image Source="{Binding ImageSource}"&gt;&lt;/Image&gt; &lt;TextBlock Text="{Binding Text}"&gt;&lt;/TextBlock&gt; &lt;/StackPanel&gt; &lt;/Grid&gt; &lt;/UserControl&gt; </code></pre> <p>With ideally DPs defined in its ViewModel, but for the time being, in code behind:</p> <pre><code>public string ImageSource { get { return (string)GetValue(ImageSourceProperty); } set { SetValue(ImageSourceProperty, value); } } // Using a DependencyProperty as the backing store for ImageSource. This enables animation, styling, binding, etc... public static readonly DependencyProperty ImageSourceProperty = DependencyProperty.Register("ImageSource", typeof(string), typeof(TabItemHeader)); public string Text { get { return (string)GetValue(TextProperty); } set { SetValue(TextProperty, value); } } // Using a DependencyProperty as the backing store for Text. This enables animation, styling, binding, etc... public static readonly DependencyProperty TextProperty = DependencyProperty.Register("Text", typeof(string), typeof(TabItemHeader)); </code></pre> <p>Then while creating your TabItem you need to set its HeaderTemplate:</p> <pre><code>TabItem tabItem = new TabItem(); tabItem.Height = 100; tabItem.Width = 50; var header = new FrameworkElementFactory(typeof(TabItemHeader)); header.SetValue(TabItemHeader.TextProperty, "This is Text"); header.SetValue(TabItemHeader.ImageSourceProperty, "This is Image uri"); header.SetValue(TabItemHeader.HeightProperty, (double)50); header.SetValue(TabItemHeader.WidthProperty, (double)50); tabItem.HeaderTemplate = new DataTemplate { VisualTree = header }; tabCategories.Items.Add(tabItem); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload