fix: Move Card to Toolkit
This commit is contained in:
Родитель
f4fbceb5bc
Коммит
b5ca4121e0
21
README.md
21
README.md
|
@ -1,2 +1,21 @@
|
|||
# Uno.Toolkit
|
||||
A set of controls for the UWP, WinUI and the Uno Platform
|
||||
A set of custom controls for the UWP, WinUI and the Uno Platform not offered out of the box by WinUI, such as Card for example.
|
||||
|
||||
### Material Styles for custom controls
|
||||
| **Controls** | **StyleNames** |
|
||||
|---------------------------|-------------------------------------------------------------------------------|
|
||||
| Card | MaterialOutlinedCardStyle <br> MaterialElevatedCardStyle <br> MaterialAvatarOutlinedCardStyle <br> MaterialAvatarElevatedCardStyle <br> MaterialSmallMediaOutlinedCardStyle <br> MaterialSmallMediaElevatedCardStyle |
|
||||
|
||||
#### Start using the styles in your pages!
|
||||
To use styles, just find the name of the style from our documentation or sample app and use it like this:
|
||||
|
||||
Here is how to use our custom controls like a Card
|
||||
```xaml
|
||||
xmlns:utu="using:Uno.Toolkit.UI.Controls"
|
||||
|
||||
[...]
|
||||
|
||||
<material:Card Header="Outlined card"
|
||||
SubHeader="With title and subitle"
|
||||
Style="{StaticResource MaterialOutlinedCardStyle}" />
|
||||
```
|
|
@ -0,0 +1,249 @@
|
|||
<Page x:Class="Uno.Toolkit.Samples.Content.Controls.CardSamplePage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:sample="using:Uno.Toolkit.Samples"
|
||||
xmlns:utu="using:Uno.Toolkit.UI.Controls"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<Page.Resources>
|
||||
<!-- Sample Button Styles -->
|
||||
<Style x:Key="IconsSampleButtonStyle"
|
||||
BasedOn="{StaticResource MaterialTextButtonStyle}"
|
||||
TargetType="Button">
|
||||
<Setter Property="Margin"
|
||||
Value="6" />
|
||||
<Setter Property="Padding"
|
||||
Value="8,12" />
|
||||
<Setter Property="HorizontalContentAlignment"
|
||||
Value="Center" />
|
||||
</Style>
|
||||
|
||||
<!-- Text Sample -->
|
||||
<x:String x:Key="SupportingTextSample">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor.</x:String>
|
||||
|
||||
<!-- Sample Supporting Content With Buttons Template -->
|
||||
<DataTemplate x:Key="SupportingWithButtonsTemplate">
|
||||
<StackPanel>
|
||||
<TextBlock Text="{Binding}"
|
||||
Margin="16,4,16,0"
|
||||
Style="{ThemeResource MaterialBody2}" />
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<Button Content="ACTION 1"
|
||||
Margin="6"
|
||||
Padding="10,2"
|
||||
Style="{StaticResource MaterialTextButtonStyle}" />
|
||||
<Button Content="ACTION 2"
|
||||
Margin="6"
|
||||
Padding="10,2"
|
||||
Style="{StaticResource MaterialTextButtonStyle}" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
|
||||
<!-- Sample Top Icon Template -->
|
||||
<DataTemplate x:Key="TopIconsTemplate">
|
||||
<Button Content="{Binding}"
|
||||
Style="{StaticResource IconsSampleButtonStyle}">
|
||||
<Button.ContentTemplate>
|
||||
<DataTemplate>
|
||||
<!-- Material more icon -->
|
||||
<Path Fill="{StaticResource MaterialOnSurfaceBrush}"
|
||||
Data="M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z" />
|
||||
</DataTemplate>
|
||||
</Button.ContentTemplate>
|
||||
</Button>
|
||||
</DataTemplate>
|
||||
|
||||
<!-- Sample Bottom Icon Template -->
|
||||
<DataTemplate x:Key="BottomIconTemplate">
|
||||
<Button Content="{Binding}"
|
||||
VerticalAlignment="Bottom"
|
||||
HorizontalAlignment="Right"
|
||||
Style="{StaticResource IconsSampleButtonStyle}">
|
||||
<Button.ContentTemplate>
|
||||
<DataTemplate>
|
||||
<!-- Material share icon -->
|
||||
<Path Fill="{StaticResource MaterialOnSurfaceBrush}"
|
||||
Data="M18 16.08c-.76 0-1.44.3-1.96.77L8.91 12.7c.05-.23.09-.46.09-.7s-.04-.47-.09-.7l7.05-4.11c.54.5 1.25.81 2.04.81 1.66 0 3-1.34 3-3s-1.34-3-3-3-3 1.34-3 3c0 .24.04.47.09.7L8.04 9.81C7.5 9.31 6.79 9 6 9c-1.66 0-3 1.34-3 3s1.34 3 3 3c.79 0 1.5-.31 2.04-.81l7.12 4.16c-.05.21-.08.43-.08.65 0 1.61 1.31 2.92 2.92 2.92 1.61 0 2.92-1.31 2.92-2.92s-1.31-2.92-2.92-2.92z" />
|
||||
</DataTemplate>
|
||||
</Button.ContentTemplate>
|
||||
</Button>
|
||||
</DataTemplate>
|
||||
</Page.Resources>
|
||||
|
||||
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||
<sample:SamplePageLayout>
|
||||
<sample:SamplePageLayout.MaterialTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Padding="0,20"
|
||||
Spacing="20">
|
||||
|
||||
<!-- Card Outlined -->
|
||||
<utu:Card HeaderContent="Outlined card"
|
||||
SubHeaderContent="With title and subtitle only"
|
||||
Style="{StaticResource MaterialOutlinedCardStyle}" />
|
||||
|
||||
<!-- Outlined disabled Card -->
|
||||
<utu:Card HeaderContent="Outlined disabled Card"
|
||||
SubHeaderContent="With title and subtitle only"
|
||||
Style="{StaticResource MaterialOutlinedCardStyle}"
|
||||
IsEnabled="False" />
|
||||
|
||||
<!-- Card Elevated -->
|
||||
<utu:Card HeaderContent="Elevated card"
|
||||
SubHeaderContent="With title and subtitle only"
|
||||
Style="{StaticResource MaterialElevatedCardStyle}" />
|
||||
|
||||
<!-- Elevated disabled Card -->
|
||||
<utu:Card HeaderContent="Elevated disabled Card"
|
||||
SubHeaderContent="With title and subtitle only"
|
||||
Style="{StaticResource MaterialElevatedCardStyle}"
|
||||
IsEnabled="False" />
|
||||
|
||||
<!-- Card Outlined With supporting text -->
|
||||
<utu:Card HeaderContent="Outlined card"
|
||||
SubHeaderContent="With supporting text"
|
||||
SupportingContent="{StaticResource SupportingTextSample}"
|
||||
Style="{StaticResource MaterialOutlinedCardStyle}" />
|
||||
|
||||
<!-- Card Elevated With supporting text -->
|
||||
<utu:Card HeaderContent="Elevated card"
|
||||
SubHeaderContent="With supporting text"
|
||||
SupportingContent="{StaticResource SupportingTextSample}"
|
||||
Style="{StaticResource MaterialElevatedCardStyle}" />
|
||||
|
||||
<!-- Card Outlined with media -->
|
||||
<utu:Card HeaderContent="Outlined card"
|
||||
SubHeaderContent="With media"
|
||||
MediaContent="ms-appx:///Assets/Media/LargeMedia.png"
|
||||
Style="{StaticResource MaterialOutlinedCardStyle}" />
|
||||
|
||||
<!-- Card Elevated with media -->
|
||||
<utu:Card HeaderContent="Elevated card"
|
||||
SubHeaderContent="With media"
|
||||
MediaContent="ms-appx:///Assets/Media/LargeMedia.png"
|
||||
Style="{StaticResource MaterialElevatedCardStyle}" />
|
||||
|
||||
<!-- Card Outlined with media and supporting text -->
|
||||
<utu:Card HeaderContent="Outlined card"
|
||||
SubHeaderContent="With media and supporting text"
|
||||
MediaContent="ms-appx:///Assets/Media/LargeMedia.png"
|
||||
SupportingContent="{StaticResource SupportingTextSample}"
|
||||
Style="{StaticResource MaterialOutlinedCardStyle}" />
|
||||
|
||||
<!-- Card Elevated with media and supporting text -->
|
||||
<utu:Card HeaderContent="Elevated card"
|
||||
SubHeaderContent="With media and supporting text"
|
||||
MediaContent="ms-appx:///Assets/Media/LargeMedia.png"
|
||||
SupportingContent="{StaticResource SupportingTextSample}"
|
||||
Style="{StaticResource MaterialElevatedCardStyle}" />
|
||||
|
||||
<!-- Card Outlined with media, supporting text and action buttons -->
|
||||
<utu:Card HeaderContent="Outlined card"
|
||||
SubHeaderContent="With media, supporting text and action buttons"
|
||||
MediaContent="ms-appx:///Assets/Media/LargeMedia.png"
|
||||
SupportingContent="{StaticResource SupportingTextSample}"
|
||||
SupportingContentTemplate="{StaticResource SupportingWithButtonsTemplate}"
|
||||
Style="{StaticResource MaterialOutlinedCardStyle}" />
|
||||
|
||||
<!-- Card Elevated with media, supporting text and action buttons -->
|
||||
<utu:Card HeaderContent="Elevated card"
|
||||
SubHeaderContent="With media, supporting text and action buttons"
|
||||
MediaContent="ms-appx:///Assets/Media/LargeMedia.png"
|
||||
SupportingContent="{StaticResource SupportingTextSample}"
|
||||
SupportingContentTemplate="{StaticResource SupportingWithButtonsTemplate}"
|
||||
Style="{StaticResource MaterialElevatedCardStyle}" />
|
||||
|
||||
<!-- Card Outlined with media, supporting text, action buttons and supplemental action buttons -->
|
||||
<utu:Card HeaderContent="Outlined card"
|
||||
SubHeaderContent="With media, supporting text, action buttons and supplemental action buttons"
|
||||
MediaContent="ms-appx:///Assets/Media/LargeMedia.png"
|
||||
SupportingContent="{StaticResource SupportingTextSample}"
|
||||
SupportingContentTemplate="{StaticResource SupportingWithButtonsTemplate}"
|
||||
IconsContentTemplate="{StaticResource BottomIconTemplate}"
|
||||
Style="{StaticResource MaterialOutlinedCardStyle}" />
|
||||
|
||||
<!-- Card Elevated with media, supporting text, action buttons and supplemental action buttons -->
|
||||
<utu:Card HeaderContent="Elevated card"
|
||||
SubHeaderContent="With media, supporting text, action buttons and supplemental action buttons"
|
||||
MediaContent="ms-appx:///Assets/Media/LargeMedia.png"
|
||||
SupportingContent="{StaticResource SupportingTextSample}"
|
||||
SupportingContentTemplate="{StaticResource SupportingWithButtonsTemplate}"
|
||||
IconsContentTemplate="{StaticResource BottomIconTemplate}"
|
||||
Style="{StaticResource MaterialElevatedCardStyle}" />
|
||||
|
||||
<!-- Card Outlined with small media and supporting text -->
|
||||
<utu:Card HeaderContent="Outlined card"
|
||||
SubHeaderContent="With small media and supporting text"
|
||||
MediaContent="ms-appx:///Assets/Media/SmallMedia.png"
|
||||
SupportingContent="{StaticResource SupportingTextSample}"
|
||||
Style="{StaticResource MaterialSmallMediaOutlinedCardStyle}" />
|
||||
|
||||
<!-- Card Outlined disabled with small media and supporting text -->
|
||||
<utu:Card HeaderContent="Disabled outlined card"
|
||||
SubHeaderContent="With small media and supporting text"
|
||||
MediaContent="ms-appx:///Assets/Media/SmallMedia.png"
|
||||
SupportingContent="{StaticResource SupportingTextSample}"
|
||||
Style="{StaticResource MaterialSmallMediaOutlinedCardStyle}"
|
||||
IsEnabled="False" />
|
||||
|
||||
<!-- Card Elevated with small media and supporting text -->
|
||||
<utu:Card HeaderContent="Elevated card"
|
||||
SubHeaderContent="With small media and supporting text"
|
||||
MediaContent="ms-appx:///Assets/Media/SmallMedia.png"
|
||||
SupportingContent="{StaticResource SupportingTextSample}"
|
||||
Style="{StaticResource MaterialSmallMediaElevatedCardStyle}" />
|
||||
|
||||
<!-- Card Elevated disabled with small media and supporting text -->
|
||||
<utu:Card HeaderContent="Disabled elevated card"
|
||||
SubHeaderContent="With small media and supporting text"
|
||||
MediaContent="ms-appx:///Assets/Media/SmallMedia.png"
|
||||
SupportingContent="{StaticResource SupportingTextSample}"
|
||||
Style="{StaticResource MaterialSmallMediaElevatedCardStyle}"
|
||||
IsEnabled="False" />
|
||||
|
||||
<!-- Card Outlined with Avatar -->
|
||||
<utu:Card HeaderContent="Outlined card"
|
||||
SubHeaderContent="With avatar"
|
||||
AvatarContent="ms-appx:///Assets/Avatar.png"
|
||||
MediaContent="ms-appx:///Assets/Media/LargeMedia.png"
|
||||
SupportingContent="{StaticResource SupportingTextSample}"
|
||||
IconsContentTemplate="{StaticResource TopIconsTemplate}"
|
||||
Style="{StaticResource MaterialAvatarOutlinedCardStyle}" />
|
||||
|
||||
<!-- Card Outlined disabled with Avatar -->
|
||||
<utu:Card HeaderContent="Disabled outlined card"
|
||||
SubHeaderContent="With avatar"
|
||||
AvatarContent="ms-appx:///Assets/Avatar.png"
|
||||
MediaContent="ms-appx:///Assets/Media/LargeMedia.png"
|
||||
SupportingContent="{StaticResource SupportingTextSample}"
|
||||
IconsContentTemplate="{StaticResource TopIconsTemplate}"
|
||||
Style="{StaticResource MaterialAvatarOutlinedCardStyle}"
|
||||
IsEnabled="False" />
|
||||
|
||||
<!-- Card Elevated with Avatar -->
|
||||
<utu:Card HeaderContent="Elevated card"
|
||||
SubHeaderContent="With avatar"
|
||||
AvatarContent="ms-appx:///Assets/Avatar.png"
|
||||
MediaContent="ms-appx:///Assets/Media/LargeMedia.png"
|
||||
SupportingContent="{StaticResource SupportingTextSample}"
|
||||
IconsContentTemplate="{StaticResource TopIconsTemplate}"
|
||||
Style="{StaticResource MaterialAvatarElevatedCardStyle}" />
|
||||
|
||||
<!-- Card Elevated disabled with Avatar -->
|
||||
<utu:Card HeaderContent="Disabled elevated card"
|
||||
SubHeaderContent="With avatar"
|
||||
AvatarContent="ms-appx:///Assets/Avatar.png"
|
||||
MediaContent="ms-appx:///Assets/Media/LargeMedia.png"
|
||||
SupportingContent="{StaticResource SupportingTextSample}"
|
||||
IconsContentTemplate="{StaticResource TopIconsTemplate}"
|
||||
Style="{StaticResource MaterialAvatarElevatedCardStyle}"
|
||||
IsEnabled="False" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</sample:SamplePageLayout.MaterialTemplate>
|
||||
</sample:SamplePageLayout>
|
||||
</Grid>
|
||||
</Page>
|
|
@ -0,0 +1,39 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
using Uno.Toolkit.Samples.Entities;
|
||||
using Windows.Foundation;
|
||||
using Windows.Foundation.Collections;
|
||||
#if IS_WINUI
|
||||
using Microsoft.UI;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.UI.Xaml.Controls.Primitives;
|
||||
using Microsoft.UI.Xaml.Data;
|
||||
using Microsoft.UI.Xaml.Input;
|
||||
using Microsoft.UI.Xaml.Media;
|
||||
using Microsoft.UI.Xaml.Navigation;
|
||||
#else
|
||||
using Windows.UI;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Controls.Primitives;
|
||||
using Windows.UI.Xaml.Data;
|
||||
using Windows.UI.Xaml.Input;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
#endif
|
||||
|
||||
namespace Uno.Toolkit.Samples.Content.Controls
|
||||
{
|
||||
[SamplePage(SampleCategory.Controls, "Card", SourceSdk.UnoMaterial, Description = "This control is used to display content and actions about a single item.", DocumentationLink = "https://material.io/components/cards")]
|
||||
public sealed partial class CardSamplePage : Page
|
||||
{
|
||||
public CardSamplePage()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -19,6 +19,9 @@
|
|||
<DependentUpon>App.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)App.xaml.Navigation.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Content\Controls\CardSamplePage.xaml.cs">
|
||||
<DependentUpon>CardSamplePage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Content\Controls\ChipSamplePage.xaml.cs">
|
||||
<DependentUpon>ChipSamplePage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
|
@ -96,6 +99,10 @@
|
|||
<PRIResource Include="$(MSBuildThisFileDirectory)Strings\en\Resources.resw" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Include="$(MSBuildThisFileDirectory)Content\Controls\CardSamplePage.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="$(MSBuildThisFileDirectory)Content\Controls\ChipSamplePage.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
|
|
|
@ -0,0 +1,167 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
#if IS_WINUI
|
||||
using Microsoft.UI;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
#else
|
||||
using Windows.UI;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
#endif
|
||||
|
||||
namespace Uno.Toolkit.UI.Controls
|
||||
{
|
||||
public partial class Card : Control
|
||||
{
|
||||
#if __ANDROID__
|
||||
private static readonly Windows.UI.Color _defaultShadowColor = Colors.Black;
|
||||
#else
|
||||
private static readonly Windows.UI.Color _defaultShadowColor = Windows.UI.Color.FromArgb(64, 0, 0, 0);
|
||||
#endif
|
||||
|
||||
#region HeaderContent and HeaderContentTemplate
|
||||
public object HeaderContent
|
||||
{
|
||||
get { return (object)GetValue(HeaderContentProperty); }
|
||||
set { SetValue(HeaderContentProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty HeaderContentProperty =
|
||||
DependencyProperty.Register("HeaderContent", typeof(object), typeof(Card), new PropertyMetadata(null));
|
||||
|
||||
public DataTemplate HeaderContentTemplate
|
||||
{
|
||||
get { return (DataTemplate)GetValue(HeaderContentTemplateProperty); }
|
||||
set { SetValue(HeaderContentTemplateProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty HeaderContentTemplateProperty =
|
||||
DependencyProperty.Register("HeaderContentTemplate", typeof(DataTemplate), typeof(Card), new PropertyMetadata(null));
|
||||
#endregion
|
||||
|
||||
#region SubHeaderContent and SubHeaderContentTemplate
|
||||
public object SubHeaderContent
|
||||
{
|
||||
get { return (object)GetValue(SubHeaderContentProperty); }
|
||||
set { SetValue(SubHeaderContentProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty SubHeaderContentProperty =
|
||||
DependencyProperty.Register("SubHeaderContent", typeof(object), typeof(Card), new PropertyMetadata(null));
|
||||
|
||||
public DataTemplate SubHeaderContentTemplate
|
||||
{
|
||||
get { return (DataTemplate)GetValue(SubHeaderContentTemplateProperty); }
|
||||
set { SetValue(SubHeaderContentTemplateProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty SubHeaderContentTemplateProperty =
|
||||
DependencyProperty.Register("SubHeaderContentTemplate", typeof(DataTemplate), typeof(Card), new PropertyMetadata(null));
|
||||
#endregion
|
||||
|
||||
#region AvatarContent and AvatarContentTemplate
|
||||
public object AvatarContent
|
||||
{
|
||||
get { return (object)GetValue(AvatarContentProperty); }
|
||||
set { SetValue(AvatarContentProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty AvatarContentProperty =
|
||||
DependencyProperty.Register("AvatarContent", typeof(object), typeof(Card), new PropertyMetadata(null));
|
||||
|
||||
public DataTemplate AvatarContentTemplate
|
||||
{
|
||||
get { return (DataTemplate)GetValue(AvatarContentTemplateProperty); }
|
||||
set { SetValue(AvatarContentTemplateProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty AvatarContentTemplateProperty =
|
||||
DependencyProperty.Register("AvatarContentTemplate", typeof(DataTemplate), typeof(Card), new PropertyMetadata(null));
|
||||
#endregion
|
||||
|
||||
#region MediaContent and MediaContentTemplate
|
||||
public object MediaContent
|
||||
{
|
||||
get { return (object)GetValue(MediaContentProperty); }
|
||||
set { SetValue(MediaContentProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty MediaContentProperty =
|
||||
DependencyProperty.Register("MediaContent", typeof(object), typeof(Card), new PropertyMetadata(null));
|
||||
|
||||
public DataTemplate MediaContentTemplate
|
||||
{
|
||||
get { return (DataTemplate)GetValue(MediaContentTemplateProperty); }
|
||||
set { SetValue(MediaContentTemplateProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty MediaContentTemplateProperty =
|
||||
DependencyProperty.Register("MediaContentTemplate", typeof(DataTemplate), typeof(Card), new PropertyMetadata(null));
|
||||
#endregion
|
||||
|
||||
#region SupportingContent and SupportingContentTemplate
|
||||
public object SupportingContent
|
||||
{
|
||||
get { return (object)GetValue(SupportingContentProperty); }
|
||||
set { SetValue(SupportingContentProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty SupportingContentProperty =
|
||||
DependencyProperty.Register("SupportingContent", typeof(object), typeof(Card), new PropertyMetadata(null));
|
||||
|
||||
public DataTemplate SupportingContentTemplate
|
||||
{
|
||||
get { return (DataTemplate)GetValue(SupportingContentTemplateProperty); }
|
||||
set { SetValue(SupportingContentTemplateProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty SupportingContentTemplateProperty =
|
||||
DependencyProperty.Register("SupportingContentTemplate", typeof(DataTemplate), typeof(Card), new PropertyMetadata(null));
|
||||
#endregion
|
||||
|
||||
#region IconsContent and IconsContentTemplate
|
||||
public object IconsContent
|
||||
{
|
||||
get { return (object)GetValue(IconsContentProperty); }
|
||||
set { SetValue(IconsContentProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty IconsContentProperty =
|
||||
DependencyProperty.Register("IconsContent", typeof(object), typeof(Card), new PropertyMetadata(null));
|
||||
|
||||
public DataTemplate IconsContentTemplate
|
||||
{
|
||||
get { return (DataTemplate)GetValue(IconsContentTemplateProperty); }
|
||||
set { SetValue(IconsContentTemplateProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty IconsContentTemplateProperty =
|
||||
DependencyProperty.Register("IconsContentTemplate", typeof(DataTemplate), typeof(Card), new PropertyMetadata(null));
|
||||
#endregion
|
||||
|
||||
#region Elevation
|
||||
public double Elevation
|
||||
{
|
||||
get { return (double)GetValue(ElevationProperty); }
|
||||
set { SetValue(ElevationProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty ElevationProperty =
|
||||
DependencyProperty.Register("Elevation", typeof(double), typeof(Card), new PropertyMetadata(0));
|
||||
#endregion
|
||||
|
||||
#region ShadowColor
|
||||
public Windows.UI.Color ShadowColor
|
||||
{
|
||||
get { return (Windows.UI.Color)GetValue(ShadowColorProperty); }
|
||||
set { SetValue(ShadowColorProperty, value); }
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty ShadowColorProperty =
|
||||
DependencyProperty.Register("ShadowColor", typeof(Windows.UI.Color), typeof(Card), new PropertyMetadata(_defaultShadowColor));
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
using Windows.ApplicationModel.Store;
|
||||
using Windows.Foundation;
|
||||
|
||||
#if IS_WINUI
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.UI.Xaml.Input;
|
||||
#else
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Input;
|
||||
#endif
|
||||
|
||||
namespace Uno.Toolkit.UI.Controls
|
||||
{
|
||||
public partial class Card : Control
|
||||
{
|
||||
public Card()
|
||||
{
|
||||
DefaultStyleKey = typeof(Card);
|
||||
}
|
||||
|
||||
protected override void OnApplyTemplate()
|
||||
{
|
||||
if (IsEnabled)
|
||||
{
|
||||
VisualStateManager.GoToState(this, "Normal", true);
|
||||
}
|
||||
else
|
||||
{
|
||||
VisualStateManager.GoToState(this, "Disabled", true);
|
||||
}
|
||||
|
||||
base.OnApplyTemplate();
|
||||
}
|
||||
|
||||
protected override void OnPointerEntered(PointerRoutedEventArgs e)
|
||||
{
|
||||
VisualStateManager.GoToState(this, "PointerOver", true);
|
||||
|
||||
base.OnPointerEntered(e);
|
||||
}
|
||||
|
||||
protected override void OnPointerExited(PointerRoutedEventArgs e)
|
||||
{
|
||||
VisualStateManager.GoToState(this, "Normal", true);
|
||||
|
||||
base.OnPointerExited(e);
|
||||
}
|
||||
|
||||
protected override void OnPointerPressed(PointerRoutedEventArgs e)
|
||||
{
|
||||
VisualStateManager.GoToState(this, "Pressed", true);
|
||||
|
||||
base.OnPointerPressed(e);
|
||||
}
|
||||
|
||||
protected override void OnPointerReleased(PointerRoutedEventArgs e)
|
||||
{
|
||||
VisualStateManager.GoToState(this, "Normal", true);
|
||||
|
||||
base.OnPointerReleased(e);
|
||||
}
|
||||
|
||||
protected override void OnGotFocus(RoutedEventArgs e)
|
||||
{
|
||||
VisualStateManager.GoToState(this, "Focused", true);
|
||||
VisualStateManager.GoToState(this, "PointerFocused", true);
|
||||
|
||||
base.OnGotFocus(e);
|
||||
}
|
||||
|
||||
protected override void OnLostFocus(RoutedEventArgs e)
|
||||
{
|
||||
VisualStateManager.GoToState(this, "Unfocused", true);
|
||||
|
||||
base.OnLostFocus(e);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -35,9 +35,11 @@ namespace Uno.Toolkit.UI.Material
|
|||
this.MergedDictionaries.Add(new ResourceDictionary { Source = new Uri($"ms-appx:///{PackageName}/Styles/Controls/TopTabBar.xaml") });
|
||||
this.MergedDictionaries.Add(new ResourceDictionary { Source = new Uri($"ms-appx:///{PackageName}/Styles/Controls/NavigationBar.xaml") });
|
||||
#endif
|
||||
|
||||
this.MergedDictionaries.Add(new ResourceDictionary { Source = new Uri($"ms-appx:///{PackageName}/Styles/Controls/Card.xaml") });
|
||||
this.MergedDictionaries.Add(new ResourceDictionary { Source = new Uri($"ms-appx:///{PackageName}/Styles/Controls/CardContentControl.xaml") });
|
||||
this.MergedDictionaries.Add(new ResourceDictionary { Source = new Uri($"ms-appx:///{PackageName}/Styles/Controls/Chip.xaml") });
|
||||
this.MergedDictionaries.Add(new ResourceDictionary { Source = new Uri($"ms-appx:///{PackageName}/Styles/Controls/ChipGroup.xaml") });
|
||||
this.MergedDictionaries.Add(new ResourceDictionary { Source = new Uri($"ms-appx:///{PackageName}/Styles/Controls/CardContentControl.xaml") });
|
||||
this.MergedDictionaries.Add(new ResourceDictionary { Source = new Uri($"ms-appx:///{PackageName}/Styles/Controls/Divider.xaml") });
|
||||
}
|
||||
}
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
Загрузка…
Ссылка в новой задаче