Skip to content

Commit

Permalink
Fix: Fixed issue with tab icon not loading properly (#11328)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelwgn authored Feb 16, 2023
1 parent 6922c25 commit 42bc25f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
Binary file modified src/Files.App/Assets/FilesOpenDialog/FilesLauncher.exe
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@
Margin="{ThemeResource TabViewItemHeaderIconMargin}">
<ContentControl
x:Name="IconControl"
Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TabViewTemplateSettings.IconElement}"
Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TabViewTemplateSettings.IconElement, Mode=OneWay}"
Foreground="{ThemeResource TabViewItemIconForeground}"
HighContrastAdjustment="None"
IsTabStop="False" />
Expand Down Expand Up @@ -609,6 +609,7 @@
Header="{x:Bind Header, Mode=OneWay}"
IconSource="{x:Bind IconSource, Mode=OneWay}"
Style="{StaticResource Local.TabViewItem}"
Loaded="TabViewItem_Loaded"
ToolTipService.ToolTip="{x:Bind ToolTipText, Mode=OneWay}" />
</DataTemplate>
</TabView.TabItemTemplate>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using CommunityToolkit.WinUI.UI;
using Files.App.Extensions;
using Files.App.Helpers;
using Files.App.ViewModels;
Expand All @@ -8,6 +9,7 @@
using System.Linq;
using Windows.ApplicationModel.DataTransfer;
using Windows.Storage;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Tab;

// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236

Expand Down Expand Up @@ -235,5 +237,18 @@ public Visibility TabStripVisibility
DependencyProperty.Register("TabStripVisibility", typeof(Visibility), typeof(HorizontalMultitaskingControl), new PropertyMetadata(Visibility.Visible));

public Rectangle DragArea => DragAreaRectangle;

private void TabViewItem_Loaded(object sender, RoutedEventArgs e)
{
if (sender is TabViewItem tvi && tvi.FindDescendant("IconControl") is ContentControl control)
{
control.Content = (tvi.IconSource as ImageIconSource).CreateIconElement();
tvi.RegisterPropertyChangedCallback(TabViewItem.IconSourceProperty, (s, args) =>
{
if (s is TabViewItem tabViewItem && tabViewItem.FindDescendant("IconControl") is ContentControl iconControl)
iconControl.Content = (tabViewItem.IconSource as ImageIconSource).CreateIconElement();
});
}
}
}
}

0 comments on commit 42bc25f

Please sign in to comment.