get customed resource

This commit is contained in:
w-mj committed 2019-04-29 14:51:47 +08:00
1 parent c80e895d4a
commit c9d18b31bf
4 files changed
+79 -1

No files matched your search

+1
View File
@@ -4,4 +4,5 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:FileManager_UWP">
</Application>
@@ -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);
}
}
+71 -1
View File
@@ -3,14 +3,84 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:FileManager_UWP.Controls">
<Style TargetType="Button" x:Key="LabelButtonStyle">
<Setter Property="Background" Value="{ThemeResource ButtonBackground}" />
<Setter Property="BackgroundSizing" Value="OuterBorderEdge" />
<Setter Property="Foreground" Value="{ThemeResource ButtonForeground}" />
<Setter Property="BorderBrush" Value="{ThemeResource ButtonBorderBrush}" />
<Setter Property="BorderThickness" Value="{ThemeResource ButtonBorderThemeThickness}" />
<Setter Property="Padding" Value="{StaticResource ButtonPadding}" />
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}" />
<Setter Property="FontWeight" Value="Normal" />
<Setter Property="FontSize" Value="{ThemeResource ControlContentThemeFontSize}" />
<Setter Property="UseSystemFocusVisuals" Value="{StaticResource UseSystemFocusVisuals}" />
<Setter Property="FocusVisualMargin" Value="-3" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<ContentPresenter x:Name="ContentPresenter"
Background="Red"
BackgroundSizing="{TemplateBinding BackgroundSizing}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
ContentTransitions="{TemplateBinding ContentTransitions}"
CornerRadius="{TemplateBinding CornerRadius}"
Padding="{TemplateBinding Padding}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
AutomationProperties.AccessibilityView="Raw">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal">
<Storyboard>
<PointerUpThemeAnimation Storyboard.TargetName="ContentPresenter" />
</Storyboard>
</VisualState>
<VisualState x:Name="PointerOver">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Background">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ButtonBackgroundPointerOver}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="BorderBrush">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ButtonBorderBrushPointerOver}" />
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Foreground">
<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource ButtonForegroundPointerOver}" />
</ObjectAnimationUsingKeyFrames>
<PointerUpThemeAnimation Storyboard.TargetName="ContentPresenter" />
</Storyboard>
</VisualState>
<VisualState x:Name="Pressed"/>
<VisualState x:Name="Disabled"/>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</ContentPresenter>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="local:LabelListControl">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="local:LabelListControl">
<StackPanel>
<TextBlock Name="LabelTextBlock"></TextBlock>
<Button Style="{StaticResource LabelButtonStyle}"> HEEEE </Button>
<Canvas Name="LabelListCanvas">
</Canvas>
</StackPanel>
</ControlTemplate>
+1
View File
@@ -8,3 +8,4 @@
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>