From c9d18b31bfee2308b23a93d5ebbb4236276def55 Mon Sep 17 00:00:00 2001 From: w-mj Date: Mon, 29 Apr 2019 14:51:47 +0800 Subject: [PATCH] get customed resource --- FileManager_UWP/App.xaml | 1 + FileManager_UWP/Controls/LabelListControl.cs | 6 ++ .../Controls/LabelListControl.xaml | 72 ++++++++++++++++++- FileManager_UWP/Themes/Generic.xaml | 1 + 4 files changed, 79 insertions(+), 1 deletion(-) diff --git a/FileManager_UWP/App.xaml b/FileManager_UWP/App.xaml index 5ab0a2e..3ca22a8 100644 --- a/FileManager_UWP/App.xaml +++ b/FileManager_UWP/App.xaml @@ -4,4 +4,5 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:FileManager_UWP"> + diff --git a/FileManager_UWP/Controls/LabelListControl.cs b/FileManager_UWP/Controls/LabelListControl.cs index fc8c7b3..c9204ad 100644 --- a/FileManager_UWP/Controls/LabelListControl.cs +++ b/FileManager_UWP/Controls/LabelListControl.cs @@ -17,8 +17,12 @@ using Windows.UI.Xaml.Media; namespace FileManager_UWP.Controls { public class LabelListControl: ItemsControl { + private ResourceDictionary genericResourceDictionary; public LabelListControl() { this.DefaultStyleKey = typeof(LabelListControl); + var uri = new Uri("ms-appx:///Controls/LabelListControl.xaml"); + genericResourceDictionary = new ResourceDictionary(); + Application.LoadComponent(genericResourceDictionary, uri); } private void ItemsSource_CollectionChanged(object sender, @@ -36,6 +40,8 @@ namespace FileManager_UWP.Controls { Button b = new Button(); b.Content = label; b.SetValue(Canvas.LeftProperty, labelListCanvas.Children.Count * 10); + //b.Style = (Style)Application.Current.Resources["LabelButtonStyle"]; + b.Style = (Style)genericResourceDictionary["LabelButtonStyle"]; labelListCanvas.Children.Add(b); } } diff --git a/FileManager_UWP/Controls/LabelListControl.xaml b/FileManager_UWP/Controls/LabelListControl.xaml index d675bcf..234b318 100644 --- a/FileManager_UWP/Controls/LabelListControl.xaml +++ b/FileManager_UWP/Controls/LabelListControl.xaml @@ -3,14 +3,84 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:FileManager_UWP.Controls"> + +