/
githubmirror
/
Files
Обзор
Документация
Войти
/
githubmirror
/
Files
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Files.App/UserControls/Menus/MenuFlyoutSubItemCustomProperties.cs
50 строк
2 KB
yair100
Feature: Improved context menu performance (#18803)
10 авг 2026, 00:06
Не верифицирован
10 авг 2026, 00:06
a47ab17
Код
Авторство
О чём код?
// Copyright (c) Files Community // Licensed under the MIT License. using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; using Microsoft.UI.Xaml.Media.Imaging; namespace Files.App.UserControls.Menus { [Microsoft.UI.Xaml.Data.Bindable] public sealed class MenuFlyoutSubItemCustomProperties : DependencyObject { public static readonly DependencyProperty BitmapIconProperty = DependencyProperty.Register("BitmapIcon", typeof(BitmapImage), typeof(MenuFlyoutSubItemCustomProperties), new PropertyMetadata(null, OnBitmapIconChanged)); public static BitmapImage GetBitmapIcon(DependencyObject obj) { return (BitmapImage)obj.GetValue(BitmapIconProperty); } public static void SetBitmapIcon(DependencyObject obj, BitmapImage value) { obj.SetValue(BitmapIconProperty, value); } private static void OnBitmapIconChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { (d as MenuFlyoutSubItem).Icon = e.NewValue is not null ? new IconSourceElement() : null; } public static readonly DependencyProperty ThemedIconStyleProperty = DependencyProperty.Register("ThemedIconStyle", typeof(Style), typeof(MenuFlyoutSubItemCustomProperties), new PropertyMetadata(null, OnThemedIconStyleChanged)); public static Style GetThemedIconStyle(DependencyObject obj) { return (Style)obj.GetValue(ThemedIconStyleProperty); } public static void SetThemedIconStyle(DependencyObject obj, Style value) { obj.SetValue(ThemedIconStyleProperty, value); } private static void OnThemedIconStyleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { // Reserve the icon column (the ThemedIcon itself is drawn by the template); mirrors the BitmapIcon path. (d as MenuFlyoutSubItem).Icon = e.NewValue is not null ? new IconSourceElement() : null; } } }