IconPack:FontAwesome Icon Disappearing In Custom TabItem
New to WPF and may have taken a wrong turn a while ago but I have everything working so far it's just the TabItem "Icon" isn't staying after I change to another tab. It disappears as though we only have one close out button.
<UserControl.Resources>
<Style BasedOn="StaticResource x:Type Controls:Tile" TargetType="Controls:Tile" x:Key="ClosableTabButton">
<Setter Property="Width"
Value="17"/>
<Setter Property="Height"
Value="17"/>
<Setter Property="Content">
<Setter.Value>
<iconPacks:PackIconFontAwesome Margin="0,0,0,0"
Width="15"
Height="15"
Kind="PlusCircleSolid"
Rotation="45"
RenderTransformOrigin="0.5,0.5"
Foreground="#FFFFFF">
</iconPacks:PackIconFontAwesome>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Content">
<Setter.Value>
<iconPacks:PackIconFontAwesome Margin="0,0,0,0"
Width="15"
Height="15"
Kind="PlusCircleSolid"
Rotation="45"
RenderTransformOrigin="0.5,0.5"
Foreground="#ff0000">
</iconPacks:PackIconFontAwesome>
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
</Style>
</UserControl.Resources>
That's my custom Tile for the Icon/Button.
<Grid>
<TabControl Name="tabControl" ItemsSource="Binding" SelectionChanged="tabControl_SelectionChanged">
<TabControl.Template>
<ControlTemplate TargetType="x:Type TabControl">
<Grid x:Name="templateRoot" ClipToBounds="true" SnapsToDevicePixels="true" KeyboardNavigation.TabNavigation="Local">
<Grid.ColumnDefinitions>
<ColumnDefinition x:Name="ColumnDefinition0"/>
<ColumnDefinition x:Name="ColumnDefinition1" Width="0"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition x:Name="RowDefinition0" Height="Auto"/>
<RowDefinition x:Name="RowDefinition1" Height="*"/>
</Grid.RowDefinitions>
<WrapPanel x:Name="headerPanel" Background="Transparent" Grid.Column="0" IsItemsHost="true" Margin="2,2,2,0" Grid.Row="0" KeyboardNavigation.TabIndex="1" Panel.ZIndex="1"/>
<Border x:Name="contentPanel" BorderBrush="TemplateBinding BorderBrush" BorderThickness="TemplateBinding BorderThickness" Background="TemplateBinding Background" Grid.Column="0" KeyboardNavigation.DirectionalNavigation="Contained" Grid.Row="1" KeyboardNavigation.TabIndex="2" KeyboardNavigation.TabNavigation="Local">
<ContentPresenter x:Name="PART_SelectedContentHost" ContentSource="SelectedContent" Margin="TemplateBinding Padding" SnapsToDevicePixels="TemplateBinding SnapsToDevicePixels"/>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="TabStripPlacement" Value="Bottom">
<Setter Property="Grid.Row" TargetName="headerPanel" Value="1"/>
<Setter Property="Grid.Row" TargetName="contentPanel" Value="0"/>
<Setter Property="Height" TargetName="RowDefinition0" Value="*"/>
<Setter Property="Height" TargetName="RowDefinition1" Value="Auto"/>
<Setter Property="Margin" TargetName="headerPanel" Value="2,0,2,2"/>
</Trigger>
<Trigger Property="TabStripPlacement" Value="Left">
<Setter Property="Grid.Row" TargetName="headerPanel" Value="0"/>
<Setter Property="Grid.Row" TargetName="contentPanel" Value="0"/>
<Setter Property="Grid.Column" TargetName="headerPanel" Value="0"/>
<Setter Property="Grid.Column" TargetName="contentPanel" Value="1"/>
<Setter Property="Width" TargetName="ColumnDefinition0" Value="Auto"/>
<Setter Property="Width" TargetName="ColumnDefinition1" Value="*"/>
<Setter Property="Height" TargetName="RowDefinition0" Value="*"/>
<Setter Property="Height" TargetName="RowDefinition1" Value="0"/>
<Setter Property="Margin" TargetName="headerPanel" Value="2,2,0,2"/>
</Trigger>
<Trigger Property="TabStripPlacement" Value="Right">
<Setter Property="Grid.Row" TargetName="headerPanel" Value="0"/>
<Setter Property="Grid.Row" TargetName="contentPanel" Value="0"/>
<Setter Property="Grid.Column" TargetName="headerPanel" Value="1"/>
<Setter Property="Grid.Column" TargetName="contentPanel" Value="0"/>
<Setter Property="Width" TargetName="ColumnDefinition0" Value="*"/>
<Setter Property="Width" TargetName="ColumnDefinition1" Value="Auto"/>
<Setter Property="Height" TargetName="RowDefinition0" Value="*"/>
<Setter Property="Height" TargetName="RowDefinition1" Value="0"/>
<Setter Property="Margin" TargetName="headerPanel" Value="0,2,2,2"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="TextElement.Foreground" TargetName="templateRoot" Value="DynamicResource x:Static SystemColors.GrayTextBrushKey"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</TabControl.Template>
<TabControl.Resources>
<DataTemplate x:Key="TabHeader" DataType="TabItem">
<Border>
<Grid>
<Grid>
<Border x:Name="border"
CornerRadius="5,5,0,0"
Background="#CC647687"
Opacity="80"/>
<Grid x:Name="headerGrid">
<Grid.ColumnDefinitions>
<ColumnDefinition Name="Col1" Width="*"></ColumnDefinition>
<ColumnDefinition Name="Col2" Width="22"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock x:Name="textInHeader" FontSize="18" Foreground="#FFFFFF" Grid.Column="0" Text="Binding RelativeSource=RelativeSource AncestorType=x:Type TabItem, Path=Header" Margin="5,0,0,0" HorizontalAlignment="Left"/>
<Controls:Tile x:Name="closeBtn" Background="Transparent" Grid.Column="1" Style="StaticResource ClosableTabButton" CommandParameter="Binding RelativeSource=RelativeSource AncestorType=x:Type TabItem, Path=Name" ToolTip="Close Tab." Click="closeBtn_Click"/>
</Grid>
</Grid>
</Grid>
</Border>
</DataTemplate>
</TabControl.Resources>
</TabControl>
</Grid>
That's my grid inside the UserControl. I can provide more information if needed.
c# wpf tabcontrol mahapps.metro tabitem
add a comment |
New to WPF and may have taken a wrong turn a while ago but I have everything working so far it's just the TabItem "Icon" isn't staying after I change to another tab. It disappears as though we only have one close out button.
<UserControl.Resources>
<Style BasedOn="StaticResource x:Type Controls:Tile" TargetType="Controls:Tile" x:Key="ClosableTabButton">
<Setter Property="Width"
Value="17"/>
<Setter Property="Height"
Value="17"/>
<Setter Property="Content">
<Setter.Value>
<iconPacks:PackIconFontAwesome Margin="0,0,0,0"
Width="15"
Height="15"
Kind="PlusCircleSolid"
Rotation="45"
RenderTransformOrigin="0.5,0.5"
Foreground="#FFFFFF">
</iconPacks:PackIconFontAwesome>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Content">
<Setter.Value>
<iconPacks:PackIconFontAwesome Margin="0,0,0,0"
Width="15"
Height="15"
Kind="PlusCircleSolid"
Rotation="45"
RenderTransformOrigin="0.5,0.5"
Foreground="#ff0000">
</iconPacks:PackIconFontAwesome>
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
</Style>
</UserControl.Resources>
That's my custom Tile for the Icon/Button.
<Grid>
<TabControl Name="tabControl" ItemsSource="Binding" SelectionChanged="tabControl_SelectionChanged">
<TabControl.Template>
<ControlTemplate TargetType="x:Type TabControl">
<Grid x:Name="templateRoot" ClipToBounds="true" SnapsToDevicePixels="true" KeyboardNavigation.TabNavigation="Local">
<Grid.ColumnDefinitions>
<ColumnDefinition x:Name="ColumnDefinition0"/>
<ColumnDefinition x:Name="ColumnDefinition1" Width="0"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition x:Name="RowDefinition0" Height="Auto"/>
<RowDefinition x:Name="RowDefinition1" Height="*"/>
</Grid.RowDefinitions>
<WrapPanel x:Name="headerPanel" Background="Transparent" Grid.Column="0" IsItemsHost="true" Margin="2,2,2,0" Grid.Row="0" KeyboardNavigation.TabIndex="1" Panel.ZIndex="1"/>
<Border x:Name="contentPanel" BorderBrush="TemplateBinding BorderBrush" BorderThickness="TemplateBinding BorderThickness" Background="TemplateBinding Background" Grid.Column="0" KeyboardNavigation.DirectionalNavigation="Contained" Grid.Row="1" KeyboardNavigation.TabIndex="2" KeyboardNavigation.TabNavigation="Local">
<ContentPresenter x:Name="PART_SelectedContentHost" ContentSource="SelectedContent" Margin="TemplateBinding Padding" SnapsToDevicePixels="TemplateBinding SnapsToDevicePixels"/>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="TabStripPlacement" Value="Bottom">
<Setter Property="Grid.Row" TargetName="headerPanel" Value="1"/>
<Setter Property="Grid.Row" TargetName="contentPanel" Value="0"/>
<Setter Property="Height" TargetName="RowDefinition0" Value="*"/>
<Setter Property="Height" TargetName="RowDefinition1" Value="Auto"/>
<Setter Property="Margin" TargetName="headerPanel" Value="2,0,2,2"/>
</Trigger>
<Trigger Property="TabStripPlacement" Value="Left">
<Setter Property="Grid.Row" TargetName="headerPanel" Value="0"/>
<Setter Property="Grid.Row" TargetName="contentPanel" Value="0"/>
<Setter Property="Grid.Column" TargetName="headerPanel" Value="0"/>
<Setter Property="Grid.Column" TargetName="contentPanel" Value="1"/>
<Setter Property="Width" TargetName="ColumnDefinition0" Value="Auto"/>
<Setter Property="Width" TargetName="ColumnDefinition1" Value="*"/>
<Setter Property="Height" TargetName="RowDefinition0" Value="*"/>
<Setter Property="Height" TargetName="RowDefinition1" Value="0"/>
<Setter Property="Margin" TargetName="headerPanel" Value="2,2,0,2"/>
</Trigger>
<Trigger Property="TabStripPlacement" Value="Right">
<Setter Property="Grid.Row" TargetName="headerPanel" Value="0"/>
<Setter Property="Grid.Row" TargetName="contentPanel" Value="0"/>
<Setter Property="Grid.Column" TargetName="headerPanel" Value="1"/>
<Setter Property="Grid.Column" TargetName="contentPanel" Value="0"/>
<Setter Property="Width" TargetName="ColumnDefinition0" Value="*"/>
<Setter Property="Width" TargetName="ColumnDefinition1" Value="Auto"/>
<Setter Property="Height" TargetName="RowDefinition0" Value="*"/>
<Setter Property="Height" TargetName="RowDefinition1" Value="0"/>
<Setter Property="Margin" TargetName="headerPanel" Value="0,2,2,2"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="TextElement.Foreground" TargetName="templateRoot" Value="DynamicResource x:Static SystemColors.GrayTextBrushKey"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</TabControl.Template>
<TabControl.Resources>
<DataTemplate x:Key="TabHeader" DataType="TabItem">
<Border>
<Grid>
<Grid>
<Border x:Name="border"
CornerRadius="5,5,0,0"
Background="#CC647687"
Opacity="80"/>
<Grid x:Name="headerGrid">
<Grid.ColumnDefinitions>
<ColumnDefinition Name="Col1" Width="*"></ColumnDefinition>
<ColumnDefinition Name="Col2" Width="22"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock x:Name="textInHeader" FontSize="18" Foreground="#FFFFFF" Grid.Column="0" Text="Binding RelativeSource=RelativeSource AncestorType=x:Type TabItem, Path=Header" Margin="5,0,0,0" HorizontalAlignment="Left"/>
<Controls:Tile x:Name="closeBtn" Background="Transparent" Grid.Column="1" Style="StaticResource ClosableTabButton" CommandParameter="Binding RelativeSource=RelativeSource AncestorType=x:Type TabItem, Path=Name" ToolTip="Close Tab." Click="closeBtn_Click"/>
</Grid>
</Grid>
</Grid>
</Border>
</DataTemplate>
</TabControl.Resources>
</TabControl>
</Grid>
That's my grid inside the UserControl. I can provide more information if needed.
c# wpf tabcontrol mahapps.metro tabitem
add a comment |
New to WPF and may have taken a wrong turn a while ago but I have everything working so far it's just the TabItem "Icon" isn't staying after I change to another tab. It disappears as though we only have one close out button.
<UserControl.Resources>
<Style BasedOn="StaticResource x:Type Controls:Tile" TargetType="Controls:Tile" x:Key="ClosableTabButton">
<Setter Property="Width"
Value="17"/>
<Setter Property="Height"
Value="17"/>
<Setter Property="Content">
<Setter.Value>
<iconPacks:PackIconFontAwesome Margin="0,0,0,0"
Width="15"
Height="15"
Kind="PlusCircleSolid"
Rotation="45"
RenderTransformOrigin="0.5,0.5"
Foreground="#FFFFFF">
</iconPacks:PackIconFontAwesome>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Content">
<Setter.Value>
<iconPacks:PackIconFontAwesome Margin="0,0,0,0"
Width="15"
Height="15"
Kind="PlusCircleSolid"
Rotation="45"
RenderTransformOrigin="0.5,0.5"
Foreground="#ff0000">
</iconPacks:PackIconFontAwesome>
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
</Style>
</UserControl.Resources>
That's my custom Tile for the Icon/Button.
<Grid>
<TabControl Name="tabControl" ItemsSource="Binding" SelectionChanged="tabControl_SelectionChanged">
<TabControl.Template>
<ControlTemplate TargetType="x:Type TabControl">
<Grid x:Name="templateRoot" ClipToBounds="true" SnapsToDevicePixels="true" KeyboardNavigation.TabNavigation="Local">
<Grid.ColumnDefinitions>
<ColumnDefinition x:Name="ColumnDefinition0"/>
<ColumnDefinition x:Name="ColumnDefinition1" Width="0"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition x:Name="RowDefinition0" Height="Auto"/>
<RowDefinition x:Name="RowDefinition1" Height="*"/>
</Grid.RowDefinitions>
<WrapPanel x:Name="headerPanel" Background="Transparent" Grid.Column="0" IsItemsHost="true" Margin="2,2,2,0" Grid.Row="0" KeyboardNavigation.TabIndex="1" Panel.ZIndex="1"/>
<Border x:Name="contentPanel" BorderBrush="TemplateBinding BorderBrush" BorderThickness="TemplateBinding BorderThickness" Background="TemplateBinding Background" Grid.Column="0" KeyboardNavigation.DirectionalNavigation="Contained" Grid.Row="1" KeyboardNavigation.TabIndex="2" KeyboardNavigation.TabNavigation="Local">
<ContentPresenter x:Name="PART_SelectedContentHost" ContentSource="SelectedContent" Margin="TemplateBinding Padding" SnapsToDevicePixels="TemplateBinding SnapsToDevicePixels"/>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="TabStripPlacement" Value="Bottom">
<Setter Property="Grid.Row" TargetName="headerPanel" Value="1"/>
<Setter Property="Grid.Row" TargetName="contentPanel" Value="0"/>
<Setter Property="Height" TargetName="RowDefinition0" Value="*"/>
<Setter Property="Height" TargetName="RowDefinition1" Value="Auto"/>
<Setter Property="Margin" TargetName="headerPanel" Value="2,0,2,2"/>
</Trigger>
<Trigger Property="TabStripPlacement" Value="Left">
<Setter Property="Grid.Row" TargetName="headerPanel" Value="0"/>
<Setter Property="Grid.Row" TargetName="contentPanel" Value="0"/>
<Setter Property="Grid.Column" TargetName="headerPanel" Value="0"/>
<Setter Property="Grid.Column" TargetName="contentPanel" Value="1"/>
<Setter Property="Width" TargetName="ColumnDefinition0" Value="Auto"/>
<Setter Property="Width" TargetName="ColumnDefinition1" Value="*"/>
<Setter Property="Height" TargetName="RowDefinition0" Value="*"/>
<Setter Property="Height" TargetName="RowDefinition1" Value="0"/>
<Setter Property="Margin" TargetName="headerPanel" Value="2,2,0,2"/>
</Trigger>
<Trigger Property="TabStripPlacement" Value="Right">
<Setter Property="Grid.Row" TargetName="headerPanel" Value="0"/>
<Setter Property="Grid.Row" TargetName="contentPanel" Value="0"/>
<Setter Property="Grid.Column" TargetName="headerPanel" Value="1"/>
<Setter Property="Grid.Column" TargetName="contentPanel" Value="0"/>
<Setter Property="Width" TargetName="ColumnDefinition0" Value="*"/>
<Setter Property="Width" TargetName="ColumnDefinition1" Value="Auto"/>
<Setter Property="Height" TargetName="RowDefinition0" Value="*"/>
<Setter Property="Height" TargetName="RowDefinition1" Value="0"/>
<Setter Property="Margin" TargetName="headerPanel" Value="0,2,2,2"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="TextElement.Foreground" TargetName="templateRoot" Value="DynamicResource x:Static SystemColors.GrayTextBrushKey"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</TabControl.Template>
<TabControl.Resources>
<DataTemplate x:Key="TabHeader" DataType="TabItem">
<Border>
<Grid>
<Grid>
<Border x:Name="border"
CornerRadius="5,5,0,0"
Background="#CC647687"
Opacity="80"/>
<Grid x:Name="headerGrid">
<Grid.ColumnDefinitions>
<ColumnDefinition Name="Col1" Width="*"></ColumnDefinition>
<ColumnDefinition Name="Col2" Width="22"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock x:Name="textInHeader" FontSize="18" Foreground="#FFFFFF" Grid.Column="0" Text="Binding RelativeSource=RelativeSource AncestorType=x:Type TabItem, Path=Header" Margin="5,0,0,0" HorizontalAlignment="Left"/>
<Controls:Tile x:Name="closeBtn" Background="Transparent" Grid.Column="1" Style="StaticResource ClosableTabButton" CommandParameter="Binding RelativeSource=RelativeSource AncestorType=x:Type TabItem, Path=Name" ToolTip="Close Tab." Click="closeBtn_Click"/>
</Grid>
</Grid>
</Grid>
</Border>
</DataTemplate>
</TabControl.Resources>
</TabControl>
</Grid>
That's my grid inside the UserControl. I can provide more information if needed.
c# wpf tabcontrol mahapps.metro tabitem
New to WPF and may have taken a wrong turn a while ago but I have everything working so far it's just the TabItem "Icon" isn't staying after I change to another tab. It disappears as though we only have one close out button.
<UserControl.Resources>
<Style BasedOn="StaticResource x:Type Controls:Tile" TargetType="Controls:Tile" x:Key="ClosableTabButton">
<Setter Property="Width"
Value="17"/>
<Setter Property="Height"
Value="17"/>
<Setter Property="Content">
<Setter.Value>
<iconPacks:PackIconFontAwesome Margin="0,0,0,0"
Width="15"
Height="15"
Kind="PlusCircleSolid"
Rotation="45"
RenderTransformOrigin="0.5,0.5"
Foreground="#FFFFFF">
</iconPacks:PackIconFontAwesome>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Content">
<Setter.Value>
<iconPacks:PackIconFontAwesome Margin="0,0,0,0"
Width="15"
Height="15"
Kind="PlusCircleSolid"
Rotation="45"
RenderTransformOrigin="0.5,0.5"
Foreground="#ff0000">
</iconPacks:PackIconFontAwesome>
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
</Style>
</UserControl.Resources>
That's my custom Tile for the Icon/Button.
<Grid>
<TabControl Name="tabControl" ItemsSource="Binding" SelectionChanged="tabControl_SelectionChanged">
<TabControl.Template>
<ControlTemplate TargetType="x:Type TabControl">
<Grid x:Name="templateRoot" ClipToBounds="true" SnapsToDevicePixels="true" KeyboardNavigation.TabNavigation="Local">
<Grid.ColumnDefinitions>
<ColumnDefinition x:Name="ColumnDefinition0"/>
<ColumnDefinition x:Name="ColumnDefinition1" Width="0"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition x:Name="RowDefinition0" Height="Auto"/>
<RowDefinition x:Name="RowDefinition1" Height="*"/>
</Grid.RowDefinitions>
<WrapPanel x:Name="headerPanel" Background="Transparent" Grid.Column="0" IsItemsHost="true" Margin="2,2,2,0" Grid.Row="0" KeyboardNavigation.TabIndex="1" Panel.ZIndex="1"/>
<Border x:Name="contentPanel" BorderBrush="TemplateBinding BorderBrush" BorderThickness="TemplateBinding BorderThickness" Background="TemplateBinding Background" Grid.Column="0" KeyboardNavigation.DirectionalNavigation="Contained" Grid.Row="1" KeyboardNavigation.TabIndex="2" KeyboardNavigation.TabNavigation="Local">
<ContentPresenter x:Name="PART_SelectedContentHost" ContentSource="SelectedContent" Margin="TemplateBinding Padding" SnapsToDevicePixels="TemplateBinding SnapsToDevicePixels"/>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="TabStripPlacement" Value="Bottom">
<Setter Property="Grid.Row" TargetName="headerPanel" Value="1"/>
<Setter Property="Grid.Row" TargetName="contentPanel" Value="0"/>
<Setter Property="Height" TargetName="RowDefinition0" Value="*"/>
<Setter Property="Height" TargetName="RowDefinition1" Value="Auto"/>
<Setter Property="Margin" TargetName="headerPanel" Value="2,0,2,2"/>
</Trigger>
<Trigger Property="TabStripPlacement" Value="Left">
<Setter Property="Grid.Row" TargetName="headerPanel" Value="0"/>
<Setter Property="Grid.Row" TargetName="contentPanel" Value="0"/>
<Setter Property="Grid.Column" TargetName="headerPanel" Value="0"/>
<Setter Property="Grid.Column" TargetName="contentPanel" Value="1"/>
<Setter Property="Width" TargetName="ColumnDefinition0" Value="Auto"/>
<Setter Property="Width" TargetName="ColumnDefinition1" Value="*"/>
<Setter Property="Height" TargetName="RowDefinition0" Value="*"/>
<Setter Property="Height" TargetName="RowDefinition1" Value="0"/>
<Setter Property="Margin" TargetName="headerPanel" Value="2,2,0,2"/>
</Trigger>
<Trigger Property="TabStripPlacement" Value="Right">
<Setter Property="Grid.Row" TargetName="headerPanel" Value="0"/>
<Setter Property="Grid.Row" TargetName="contentPanel" Value="0"/>
<Setter Property="Grid.Column" TargetName="headerPanel" Value="1"/>
<Setter Property="Grid.Column" TargetName="contentPanel" Value="0"/>
<Setter Property="Width" TargetName="ColumnDefinition0" Value="*"/>
<Setter Property="Width" TargetName="ColumnDefinition1" Value="Auto"/>
<Setter Property="Height" TargetName="RowDefinition0" Value="*"/>
<Setter Property="Height" TargetName="RowDefinition1" Value="0"/>
<Setter Property="Margin" TargetName="headerPanel" Value="0,2,2,2"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="TextElement.Foreground" TargetName="templateRoot" Value="DynamicResource x:Static SystemColors.GrayTextBrushKey"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</TabControl.Template>
<TabControl.Resources>
<DataTemplate x:Key="TabHeader" DataType="TabItem">
<Border>
<Grid>
<Grid>
<Border x:Name="border"
CornerRadius="5,5,0,0"
Background="#CC647687"
Opacity="80"/>
<Grid x:Name="headerGrid">
<Grid.ColumnDefinitions>
<ColumnDefinition Name="Col1" Width="*"></ColumnDefinition>
<ColumnDefinition Name="Col2" Width="22"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock x:Name="textInHeader" FontSize="18" Foreground="#FFFFFF" Grid.Column="0" Text="Binding RelativeSource=RelativeSource AncestorType=x:Type TabItem, Path=Header" Margin="5,0,0,0" HorizontalAlignment="Left"/>
<Controls:Tile x:Name="closeBtn" Background="Transparent" Grid.Column="1" Style="StaticResource ClosableTabButton" CommandParameter="Binding RelativeSource=RelativeSource AncestorType=x:Type TabItem, Path=Name" ToolTip="Close Tab." Click="closeBtn_Click"/>
</Grid>
</Grid>
</Grid>
</Border>
</DataTemplate>
</TabControl.Resources>
</TabControl>
</Grid>
That's my grid inside the UserControl. I can provide more information if needed.
c# wpf tabcontrol mahapps.metro tabitem
c# wpf tabcontrol mahapps.metro tabitem
asked Nov 15 '18 at 0:17
ByrdByrd
416
416
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
I figured it out. I was setting the content of the style but it only affected the last tab that was added. It was because I wasn't setting the templates content. Which makes sense.
<UserControl.Resources>
<Style BasedOn="StaticResource x:Type Controls:Tile" TargetType="Controls:Tile" x:Key="ClosableTabButton">
<Setter Property="Width"
Value="17"/>
<Setter Property="Height"
Value="17"/>
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<iconPacks:PackIconFontAwesome Margin="0,0,0,0"
Width="15"
Height="15"
Kind="PlusCircleSolid"
Rotation="45"
RenderTransformOrigin="0.5,0.5"
Foreground="#FFFFFF">
</iconPacks:PackIconFontAwesome>
</DataTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<iconPacks:PackIconFontAwesome Margin="0,0,0,0"
Width="15"
Height="15"
Kind="PlusCircleSolid"
Rotation="45"
RenderTransformOrigin="0.5,0.5"
Foreground="#ff0000">
</iconPacks:PackIconFontAwesome>
</DataTemplate>
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
</Style>
</UserControl.Resources>
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53310706%2ficonpackfontawesome-icon-disappearing-in-custom-tabitem%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I figured it out. I was setting the content of the style but it only affected the last tab that was added. It was because I wasn't setting the templates content. Which makes sense.
<UserControl.Resources>
<Style BasedOn="StaticResource x:Type Controls:Tile" TargetType="Controls:Tile" x:Key="ClosableTabButton">
<Setter Property="Width"
Value="17"/>
<Setter Property="Height"
Value="17"/>
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<iconPacks:PackIconFontAwesome Margin="0,0,0,0"
Width="15"
Height="15"
Kind="PlusCircleSolid"
Rotation="45"
RenderTransformOrigin="0.5,0.5"
Foreground="#FFFFFF">
</iconPacks:PackIconFontAwesome>
</DataTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<iconPacks:PackIconFontAwesome Margin="0,0,0,0"
Width="15"
Height="15"
Kind="PlusCircleSolid"
Rotation="45"
RenderTransformOrigin="0.5,0.5"
Foreground="#ff0000">
</iconPacks:PackIconFontAwesome>
</DataTemplate>
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
</Style>
</UserControl.Resources>
add a comment |
I figured it out. I was setting the content of the style but it only affected the last tab that was added. It was because I wasn't setting the templates content. Which makes sense.
<UserControl.Resources>
<Style BasedOn="StaticResource x:Type Controls:Tile" TargetType="Controls:Tile" x:Key="ClosableTabButton">
<Setter Property="Width"
Value="17"/>
<Setter Property="Height"
Value="17"/>
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<iconPacks:PackIconFontAwesome Margin="0,0,0,0"
Width="15"
Height="15"
Kind="PlusCircleSolid"
Rotation="45"
RenderTransformOrigin="0.5,0.5"
Foreground="#FFFFFF">
</iconPacks:PackIconFontAwesome>
</DataTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<iconPacks:PackIconFontAwesome Margin="0,0,0,0"
Width="15"
Height="15"
Kind="PlusCircleSolid"
Rotation="45"
RenderTransformOrigin="0.5,0.5"
Foreground="#ff0000">
</iconPacks:PackIconFontAwesome>
</DataTemplate>
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
</Style>
</UserControl.Resources>
add a comment |
I figured it out. I was setting the content of the style but it only affected the last tab that was added. It was because I wasn't setting the templates content. Which makes sense.
<UserControl.Resources>
<Style BasedOn="StaticResource x:Type Controls:Tile" TargetType="Controls:Tile" x:Key="ClosableTabButton">
<Setter Property="Width"
Value="17"/>
<Setter Property="Height"
Value="17"/>
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<iconPacks:PackIconFontAwesome Margin="0,0,0,0"
Width="15"
Height="15"
Kind="PlusCircleSolid"
Rotation="45"
RenderTransformOrigin="0.5,0.5"
Foreground="#FFFFFF">
</iconPacks:PackIconFontAwesome>
</DataTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<iconPacks:PackIconFontAwesome Margin="0,0,0,0"
Width="15"
Height="15"
Kind="PlusCircleSolid"
Rotation="45"
RenderTransformOrigin="0.5,0.5"
Foreground="#ff0000">
</iconPacks:PackIconFontAwesome>
</DataTemplate>
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
</Style>
</UserControl.Resources>
I figured it out. I was setting the content of the style but it only affected the last tab that was added. It was because I wasn't setting the templates content. Which makes sense.
<UserControl.Resources>
<Style BasedOn="StaticResource x:Type Controls:Tile" TargetType="Controls:Tile" x:Key="ClosableTabButton">
<Setter Property="Width"
Value="17"/>
<Setter Property="Height"
Value="17"/>
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<iconPacks:PackIconFontAwesome Margin="0,0,0,0"
Width="15"
Height="15"
Kind="PlusCircleSolid"
Rotation="45"
RenderTransformOrigin="0.5,0.5"
Foreground="#FFFFFF">
</iconPacks:PackIconFontAwesome>
</DataTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<iconPacks:PackIconFontAwesome Margin="0,0,0,0"
Width="15"
Height="15"
Kind="PlusCircleSolid"
Rotation="45"
RenderTransformOrigin="0.5,0.5"
Foreground="#ff0000">
</iconPacks:PackIconFontAwesome>
</DataTemplate>
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
</Style>
</UserControl.Resources>
answered Nov 15 '18 at 19:25
ByrdByrd
416
416
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53310706%2ficonpackfontawesome-icon-disappearing-in-custom-tabitem%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown