Merge branch 'master' into HeaderedControls

This commit is contained in:
Shawn Kendrot 2017-11-07 10:08:28 -07:00
Родитель 546be9c70f b1f0cd506f
Коммит 6a5da01e9d
59 изменённых файлов: 1950 добавлений и 405 удалений

2
.github/ISSUE_TEMPLATE.md поставляемый
Просмотреть файл

@ -42,11 +42,13 @@ Package Version(s):
Windows 10 Build Number:
- [ ] Anniversary Update (14393)
- [ ] Creators Update (15063)
- [ ] Fall Creators Update (16299)
- [ ] Insider Build (xxxxx)
App min and target version:
- [ ] Anniversary Update (14393)
- [ ] Creators Update (15063)
- [ ] Fall Creators Update (16299)
- [ ] Insider Build (xxxxx)
Device form factor:

Просмотреть файл

@ -22,8 +22,8 @@
<IsSampleProject>$(MSBuildProjectName.Contains('Sample'))</IsSampleProject>
<UwpMetaPackageVersion>5.3.4</UwpMetaPackageVersion>
<DefaultTargetPlatformVersion>15063</DefaultTargetPlatformVersion>
<UwpMetaPackageVersion>5.4.1</UwpMetaPackageVersion>
<DefaultTargetPlatformVersion>16299</DefaultTargetPlatformVersion>
<DefaultTargetPlatformMinVersion>14393</DefaultTargetPlatformMinVersion>
</PropertyGroup>

Просмотреть файл

@ -5,6 +5,9 @@
<Description>This .NET standard library enables access to different data sources such as Bing. It is part of the UWP Community Toolkit.</Description>
<PackageTags>UWP Toolkit Windows Bing</PackageTags>
<Title>UWP Community Toolkit .NET Standard Services</Title>
<!-- This is a temporary workaround for https://github.com/dotnet/sdk/issues/955 -->
<DebugType>Full</DebugType>
</PropertyGroup>
<ItemGroup>

Просмотреть файл

@ -7,12 +7,19 @@
<PackageTags>UWP Toolkit Windows Controls XAML Developer Tools Accessibility</PackageTags>
<UseUwpMetaPackage>true</UseUwpMetaPackage>
</PropertyGroup>
<Import Project="$(MSBuildSDKExtrasTargets)" Condition="Exists('$(MSBuildSDKExtrasTargets)')" />
<ItemGroup>
<None Include="VisualStudioToolsManifest.xml" Pack="true" PackagePath="tools" />
</ItemGroup>
<!-- https://weblogs.asp.net/rweigelt/disable-warnings-in-generated-c-files-of-uwp-app -->
<Target Name="PragmaWarningDisablePrefixer" AfterTargets="MarkupCompilePass2">
<ItemGroup>
<GeneratedCSFiles Include="**\*.g.cs;**\*.g.i.cs" />
</ItemGroup>
<Message Text="CSFiles: @(GeneratedCSFiles->'&quot;%(Identity)&quot;')" />
<Exec Command="for %%f in (@(GeneratedCSFiles->'&quot;%(Identity)&quot;')) do echo #pragma warning disable &gt; %%f.temp &amp;&amp; type %%f &gt;&gt; %%f.temp &amp;&amp; move /y %%f.temp %%f &gt; NUL" />
</Target>
</Project>

Просмотреть файл

@ -10,7 +10,7 @@ Supports adaptive tiles and adaptive/interactive toasts for Windows 10. It is pa
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'uap10.0' or '$(TargetFramework)' == 'native' ">
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform" Version="5.3.4" />
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform" Version="5.4.1" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'native' ">

Просмотреть файл

@ -11,7 +11,7 @@
<AssemblyName>Microsoft.Toolkit.Uwp.SampleApp</AssemblyName>
<DefaultLanguage>en-US</DefaultLanguage>
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
<TargetPlatformVersion>10.0.15063.0</TargetPlatformVersion>
<TargetPlatformVersion>10.0.16299.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.14393.0</TargetPlatformMinVersion>
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
<FileAlignment>512</FileAlignment>
@ -119,7 +119,7 @@
<Version>4.1.6</Version>
</PackageReference>
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
<Version>5.3.4</Version>
<Version>5.4.1</Version>
</PackageReference>
<PackageReference Include="Monaco.Editor">
<Version>0.3.0-alpha</Version>
@ -1091,4 +1091,13 @@
</AppxPackagePayload>
</ItemGroup>
</Target>
<!-- https://weblogs.asp.net/rweigelt/disable-warnings-in-generated-c-files-of-uwp-app -->
<Target Name="PragmaWarningDisablePrefixer" AfterTargets="MarkupCompilePass2">
<ItemGroup>
<GeneratedCSFiles Include="**\*.g.cs;**\*.g.i.cs" />
</ItemGroup>
<Message Text="CSFiles: @(GeneratedCSFiles->'&quot;%(Identity)&quot;')" />
<Exec Command="for %%f in (@(GeneratedCSFiles->'&quot;%(Identity)&quot;')) do echo #pragma warning disable &gt; %%f.temp &amp;&amp; type %%f | findstr /v /b &quot;#pragma&quot; &gt;&gt; %%f.temp &amp;&amp; move /y %%f.temp %%f &gt; NUL" />
</Target>
</Project>

Просмотреть файл

@ -337,7 +337,7 @@ namespace Microsoft.Toolkit.Uwp.SampleApp
// Get Xaml code
using (var codeStream = await StreamHelper.GetPackagedFileStreamAsync($"SamplePages/{Name}/{XamlCodeFile}"))
{
XamlCode = await codeStream.ReadTextAsync();
XamlCode = await codeStream.ReadTextAsync(Encoding.UTF8);
// Look for @[] values and generate associated properties
var regularExpression = new Regex(@"@\[(?<name>.+?)(:(?<type>.+?):(?<value>.+?)(:(?<parameters>.+?))?(:(?<options>.*))*)?\]@?");

Просмотреть файл

@ -11,15 +11,14 @@
<Grid>
<Border Background="Gray" Width="200" Height="200">
<Image x:Name="ToolkitLogo" Source="ms-appx:///Assets/ToolkitLogo.png" Height="100" Width="100" >
<interactivity:Interaction.Behaviors>
<behaviors:Blur x:Name="BlurBehavior"
Value="@[Value:DoubleSlider:1.0:0.0-10.0]"
Duration="@[Duration:DoubleSlider:3000.0:0.0-10000.0]"
Delay="@[Delay:DoubleSlider:0.0:0.0-5000.0]"
AutomaticallyStart="@[AutomaticallyStart:Bool:True]"/>
</interactivity:Interaction.Behaviors>
</Image>
<Image x:Name="ToolkitLogo" Source="ms-appx:///Assets/ToolkitLogo.png" Height="100" Width="100" />
<interactivity:Interaction.Behaviors>
<behaviors:Blur x:Name="BlurBehavior"
Value="@[Value:DoubleSlider:1.0:0.0-10.0]"
Duration="@[Duration:DoubleSlider:3000.0:0.0-10000.0]"
Delay="@[Delay:DoubleSlider:0.0:0.0-5000.0]"
AutomaticallyStart="@[AutomaticallyStart:Bool:True]"/>
</interactivity:Interaction.Behaviors>
</Border>
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Top">
<Button Content="Apply" Margin="10">

Просмотреть файл

@ -11,34 +11,44 @@
<ScrollViewer>
<StackPanel Margin="20">
<controls:Expander x:Name="Expander1" VerticalAlignment="Top" Margin="0,0,0,10"
Header="This is the header - expander 1"
HorizontalContentAlignment="Stretch"
Foreground="White"
Background="{Binding Path=BackgroundExpander1.Value, Mode=TwoWay}"
IsExpanded="{Binding Path=IsExpanded1.Value, Mode=TwoWay}"
ExpandDirection="{Binding Path=ExpandDirection1.Value, Mode=TwoWay}">
Header="This is the header - expander 1"
HorizontalContentAlignment="Stretch"
Foreground="White"
Background="{Binding Path=BackgroundExpander1.Value, Mode=TwoWay}"
IsExpanded="{Binding Path=IsExpanded1.Value, Mode=TwoWay}"
ExpandDirection="{Binding Path=ExpandDirection1.Value, Mode=TwoWay}"
DisplayMode="{Binding Path=DisplayMode1.Value, Mode=TwoWay}">
<Grid Height="250">
<TextBlock HorizontalAlignment="Center"
TextWrapping="Wrap"
Text="This is the content"
VerticalAlignment="Center"
Style="{StaticResource HeaderTextBlockStyle}" />
TextWrapping="Wrap"
Text="This is the content"
VerticalAlignment="Center"
Style="{StaticResource HeaderTextBlockStyle}" />
</Grid>
<controls:Expander.ContentOverlay>
<Grid Background="Red">
<TextBlock Text="Hello world!"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
</Grid>
</controls:Expander.ContentOverlay>
</controls:Expander>
<controls:Expander x:Name="Expander2" VerticalAlignment="Top" Margin="0"
Header="This is the header - expander 2"
HorizontalContentAlignment="Stretch"
Foreground="White"
Background="{Binding Path=BackgroundExpander2.Value, Mode=TwoWay}"
IsExpanded="{Binding Path=IsExpanded2.Value, Mode=TwoWay}"
ExpandDirection="{Binding Path=ExpandDirection2.Value, Mode=TwoWay}">
Header="This is the header - expander 2"
HorizontalContentAlignment="Stretch"
Foreground="White"
Background="{Binding Path=BackgroundExpander2.Value, Mode=TwoWay}"
IsExpanded="{Binding Path=IsExpanded2.Value, Mode=TwoWay}"
ExpandDirection="{Binding Path=ExpandDirection2.Value, Mode=TwoWay}"
DisplayMode="{Binding Path=DisplayMode2.Value, Mode=TwoWay}">
<Grid Height="250">
<TextBlock HorizontalAlignment="Center"
TextWrapping="Wrap"
Text="This is the content"
VerticalAlignment="Center"
Style="{StaticResource HeaderTextBlockStyle}" />
TextWrapping="Wrap"
Text="This is the content"
VerticalAlignment="Center"
Style="{StaticResource HeaderTextBlockStyle}" />
</Grid>
</controls:Expander>
</StackPanel>

Просмотреть файл

@ -9,33 +9,45 @@
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<ScrollViewer>
<StackPanel Margin="20">
<controls:Expander x:Name="Expander1" VerticalAlignment="Top" Margin="0,0,0,10"
Header="This is the header - expander 1"
Foreground="White"
Background="@[BackgroundExpander1:Brush:Gray]"
IsExpanded="@[IsExpanded1:Bool:False]@"
ExpandDirection="@[ExpandDirection1:Enum:ExpandDirection.Down]">
<controls:Expander x:Name="Expander1" VerticalAlignment="Top" Margin="0,0,0,10"
Header="This is the header - expander 1"
HorizontalContentAlignment="Stretch"
Foreground="White"
Background="@[BackgroundExpander1:Brush:Gray]"
IsExpanded="@[IsExpanded1:Bool:False]@"
ExpandDirection="@[ExpandDirection1:Enum:ExpandDirection.Down]"
DisplayMode="@[DisplayMode1:Enum:ExpanderDisplayMode.Overlay]">
<Grid Height="250">
<TextBlock HorizontalAlignment="Center"
TextWrapping="Wrap"
Text="This is the content"
VerticalAlignment="Center"
Style="{StaticResource HeaderTextBlockStyle}" />
TextWrapping="Wrap"
Text="This is the content"
VerticalAlignment="Center"
Style="{StaticResource HeaderTextBlockStyle}" />
</Grid>
<controls:Expander.ContentOverlay>
<Grid Background="Red">
<TextBlock Text="Hello world!"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
</Grid>
</controls:Expander.ContentOverlay>
</controls:Expander>
<controls:Expander x:Name="Expander2" VerticalAlignment="Top" Margin="0"
Header="This is the header - expander 2"
Foreground="White"
Background="@[BackgroundExpander2:Brush:Black]"
IsExpanded="@[IsExpanded2:Bool:True]@"
ExpandDirection="@[ExpandDirection2:Enum:ExpandDirection.Right]">
<controls:Expander x:Name="Expander2" VerticalAlignment="Top" Margin="0"
Header="This is the header - expander 2"
HorizontalContentAlignment="Stretch"
Foreground="White"
Background="@[BackgroundExpander2:Brush:Black]"
IsExpanded="@[IsExpanded2:Bool:True]@"
ExpandDirection="@[ExpandDirection2:Enum:ExpandDirection.Right]"
DisplayMode="@[DisplayMode2:Enum:ExpanderDisplayMode.Expand]">
<Grid Height="250">
<TextBlock HorizontalAlignment="Center"
TextWrapping="Wrap"
Text="This is the content"
VerticalAlignment="Center"
Style="{StaticResource HeaderTextBlockStyle}" />
TextWrapping="Wrap"
Text="This is the content"
VerticalAlignment="Center"
Style="{StaticResource HeaderTextBlockStyle}" />
</Grid>
</controls:Expander>
</StackPanel>

Просмотреть файл

@ -18,10 +18,10 @@
FontSize="16"
FontFamily="Segoe MDL2 Assets"
Glyph="{Binding Glyph}"
Foreground="White" />
Foreground="Black" />
<TextBlock Grid.Column="1"
Text="{Binding Label}"
Foreground="White"
Foreground="Black"
FontSize="16"
VerticalAlignment="Center" />
</Grid>
@ -36,7 +36,7 @@
<Image Source="{Binding Thumbnail}" Stretch="UniformToFill" Margin="16,12" />
<TextBlock Grid.Column="1"
Text="{Binding Label}"
Foreground="White"
Foreground="Black"
FontSize="16"
VerticalAlignment="Center" />
</Grid>
@ -44,8 +44,10 @@
</Page.Resources>
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Margin="50" BorderThickness="1" BorderBrush="Black">
<controls:HamburgerMenu PaneBackground="@[PaneBackground:Brush:Black]" x:Name="HamburgerMenu"
Foreground="White"
<controls:HamburgerMenu x:Name="HamburgerMenu"
PaneBackground="@[PaneBackground:Brush:LightGray]"
PaneForeground="Black"
SelectedIndex="@[SelectedIndex:Slider:0:0-3]@"
ItemTemplate="{StaticResource HamburgerMenuImageItem}"
OptionsItemTemplate="{StaticResource HamburgerMenuItem}"
OpenPaneLength="@[OpenPaneLength:Slider:240:50-400]"
@ -53,7 +55,8 @@
CompactPaneLength="@[CompactPaneLength:Slider:48:10-80]"
HamburgerHeight="@[HamburgerHeight:Slider:48:10-80]"
HamburgerVisibility="@[HamburgerVisibility:Enum:Visibility.Visible]"
IsPaneOpen="@[IsPaneOpen:Bool:False]@">
IsPaneOpen="@[IsPaneOpen:Bool:False]@"
UseNavigationViewWhenPossible="@[UseNavigationViewWhenPossible:Bool:True]">
<!-- Items -->
<controls:HamburgerMenu.ItemsSource>
<controls:HamburgerMenuItemCollection>
@ -83,12 +86,12 @@
<RowDefinition />
</Grid.RowDefinitions>
<Border Grid.Row="0"
Background="Black">
Background="LightGray">
<TextBlock x:Name="Header"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="24"
Foreground="White"
Foreground="Black"
Text="{Binding Label}" />
</Border>
<Image x:Name="Image"

Просмотреть файл

@ -22,6 +22,7 @@ namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages
{
public sealed partial class HamburgerMenuPage : IXamlRenderListener
{
#pragma warning disable CS0618 // Type or member is obsolete
private HamburgerMenu hamburgerMenuControl;
private Grid contentGrid;
@ -36,25 +37,24 @@ namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages
hamburgerMenuControl = control.FindDescendantByName("HamburgerMenu") as HamburgerMenu;
if (hamburgerMenuControl != null)
{
hamburgerMenuControl.ItemClick += HamburgerMenu_OnItemClick;
hamburgerMenuControl.OptionsItemClick += HamburgerMenu_OnOptionsItemClick;
hamburgerMenuControl.ItemInvoked += HamburgerMenuControl_ItemInvoked;
}
}
private void HamburgerMenu_OnItemClick(object sender, ItemClickEventArgs e)
private async void HamburgerMenuControl_ItemInvoked(object sender, HamburgetMenuItemInvokedEventArgs e)
{
if (contentGrid != null)
if (e.IsItemOptions)
{
contentGrid.DataContext = e.ClickedItem;
var menuItem = e.InvokedItem as HamburgerMenuItem;
var dialog = new MessageDialog($"You clicked on {menuItem.Label} button");
await dialog.ShowAsync();
}
else if (contentGrid != null)
{
contentGrid.DataContext = e.InvokedItem;
}
}
private async void HamburgerMenu_OnOptionsItemClick(object sender, ItemClickEventArgs e)
{
var menuItem = e.ClickedItem as HamburgerMenuItem;
var dialog = new MessageDialog($"You clicked on {menuItem.Label} button");
await dialog.ShowAsync();
}
#pragma warning restore CS0618 // Type or member is obsolete
}
}

Просмотреть файл

@ -38,6 +38,15 @@
Source="/Assets/Photos/LunchBreak.jpg"
PlaceholderSource="/Assets/Photos/ImageExPlaceholder.jpg"
Style="{StaticResource RectangleStyle}"/>
<controls:ImageEx x:Name="ImageExControl2"
IsCacheEnabled="@[Enable Cache:Bool:True]"
Source="/Assets/Photos/LunchBreak.jpg"
PlaceholderSource="/Assets/Photos/ImageExPlaceholder.jpg"
CornerRadius="30,60,30,60"
Style="{StaticResource RectangleStyle}"/>
<TextBlock Text="Above ImageEx will have rounded corners on the Fall Creators Update." Margin="4" HorizontalAlignment="Center"/>
<controls:RoundImageEx x:Name="RoundImageExControl1"
IsCacheEnabled="@[Enable Cache]"

Просмотреть файл

@ -97,9 +97,11 @@ namespace Microsoft.Toolkit.Uwp.SampleApp.SamplePages
ImageExBase newImage = null;
if (round)
{
#pragma warning disable CS0618 // Type or member is obsolete
newImage = new RoundImageEx
{
};
#pragma warning restore CS0618 // Type or member is obsolete
if (resources?.ContainsKey("RoundStyle") == true)
{

Просмотреть файл

@ -40,7 +40,8 @@
RightCommandParameter="{Binding DataContext, RelativeSource={RelativeSource TemplatedParent}}"
RightForeground ="@[Right Foreground:Brush:White]"
RightIcon="@[Right Icon:Enum:Symbol.Delete]"
RightLabel="@[Right Label:String:Delete]">
RightLabel="@[Right Label:String:Delete]"
UseSwipeControlWhenPossible="@[UseSwipeControlWhenPossible:Bool:True]">
<Grid Height="110" Background="#FFDDDDDD">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="48" />

Просмотреть файл

@ -34,10 +34,11 @@
{
"Name": "HamburgerMenu",
"Type": "HamburgerMenuPage",
"About": "The HamburgerMenu provides a simple to use side bar menu that you can show/hide using a hamburger button.",
"About": "The HamburgerMenu is deprecated and will be removed in a future major release. Please use the NavigationView available in the Fall Creators Update.",
"CodeUrl": "https://github.com/Microsoft/UWPCommunityToolkit/tree/master/Microsoft.Toolkit.Uwp.UI.Controls/HamburgerMenu",
"XamlCodeFile": "HamburgerMenuCode.bind",
"Icon": "/SamplePages/HamburgerMenu/HamburgerMenu.png",
"BadgeUpdateVersionRequired": "DEPRECATED",
"DocumentationUrl": "https://raw.githubusercontent.com/Microsoft/UWPCommunityToolkit/master/docs/controls/HamburgerMenu.md"
},
{
@ -108,10 +109,11 @@
{
"Name": "SlidableListItem",
"Type": "SlidableListItemPage",
"About": "A UI control that enables actions to be triggered by sliding the content left or right. In most cases, it will be used as a ListView DataTemplate root similar to email apps, but it is not required.",
"About": "The SlidableListItem is deprecated and will be removed in a future major release. Please use the SwipeControl available in the Fall Creators Update.",
"CodeUrl": "https://github.com/Microsoft/UWPCommunityToolkit/tree/master/Microsoft.Toolkit.Uwp.UI.Controls/SlidableListItem",
"XamlCodeFile": "SlidableListItemCode.bind",
"Icon": "/SamplePages/SlidableListItem/SlidableListItem.png",
"BadgeUpdateVersionRequired": "DEPRECATED",
"DocumentationUrl": "https://raw.githubusercontent.com/Microsoft/UWPCommunityToolkit/master/docs/controls/SlidableListItem.md"
},
{
@ -389,10 +391,11 @@
{
"Name": "ParallaxService",
"Type": "ParallaxPage",
"About": "Parallax items contained within an element that scrolls like a ScrollViewer or ListView",
"About": "The ParallaxService is deprecated and will be removed in a future major release. Please use the ParallaxView available in the Fall Creators Update.",
"CodeUrl": "https://github.com/Microsoft/UWPCommunityToolkit/tree/master/Microsoft.Toolkit.Uwp.UI.Animations",
"XamlCodeFile": "ParallaxPage.bind",
"Icon": "/SamplePages/ParallaxService/Parallax.png",
"BadgeUpdateVersionRequired": "DEPRECATED",
"DocumentationUrl": "https://raw.githubusercontent.com/Microsoft/UWPCommunityToolkit/master/docs/animations/ParallaxService.md"
},
{

Просмотреть файл

@ -11,7 +11,7 @@
<AssemblyName>Microsoft.Toolkit.Uwp.Samples.BackgroundTasks</AssemblyName>
<DefaultLanguage>fr-FR</DefaultLanguage>
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
<TargetPlatformVersion>10.0.15063.0</TargetPlatformVersion>
<TargetPlatformVersion>10.0.16299.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.14393.0</TargetPlatformMinVersion>
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
<FileAlignment>512</FileAlignment>
@ -117,7 +117,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
<Version>5.3.4</Version>
<Version>5.4.1</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>

Просмотреть файл

@ -10,6 +10,7 @@
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
using System;
using Microsoft.Toolkit.Uwp.UI.Extensions;
using Windows.UI.Composition;
using Windows.UI.Xaml;
@ -21,16 +22,19 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
/// <summary>
/// Provides the ability to create a parallax effect to items within a ScrollViewer or List control
/// </summary>
[Obsolete("The ParallaxService will be removed in a future major release. Please use the ParallaxView control available in the Fall Creators Update")]
public class ParallaxService
{
/// <summary>
/// Identifies the ParallaxService.VerticalMultiplier XAML attached property.
/// </summary>
[Obsolete("The ParallaxService will be removed in a future major release. Please use the ParallaxView control available in the Fall Creators Update")]
public static readonly DependencyProperty VerticalMultiplierProperty = DependencyProperty.RegisterAttached("VerticalMultiplier", typeof(double), typeof(ParallaxService), new PropertyMetadata(0d, OnMultiplierChanged));
/// <summary>
/// Identifies the ParallaxService.HorizontalMultiplier attached property.
/// </summary>
[Obsolete("The ParallaxService will be removed in a future major release. Please use the ParallaxView control available in the Fall Creators Update")]
public static readonly DependencyProperty HorizontalMultiplierProperty = DependencyProperty.RegisterAttached("HorizontalMultiplier", typeof(double), typeof(ParallaxService), new PropertyMetadata(0d, OnMultiplierChanged));
/// <summary>
@ -38,6 +42,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
/// </summary>
/// <param name="element">The target element for the attached property value..</param>
/// <returns>A value for how fast the parallax effect should scroll vertically.</returns>
[Obsolete("The ParallaxService will be removed in a future major release. Please use the ParallaxView control available in the Fall Creators Update")]
public static double GetVerticalMultiplier(UIElement element)
{
return (double)element.GetValue(VerticalMultiplierProperty);
@ -48,6 +53,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
/// </summary>
/// <param name="element">The target element for the attached property value.</param>
/// <param name="value">The value for how fast the parallax effect should scroll vertically.</param>
[Obsolete("The ParallaxService will be removed in a future major release. Please use the ParallaxView control available in the Fall Creators Update")]
public static void SetVerticalMultiplier(UIElement element, double value)
{
element.SetValue(VerticalMultiplierProperty, value);
@ -58,6 +64,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
/// </summary>
/// <param name="element">The target element for the attached property value..</param>
/// <returns>A value for how fast the parallax effect should scroll vertically.</returns>
[Obsolete("The ParallaxService will be removed in a future major release. Please use the ParallaxView control available in the Fall Creators Update")]
public static double GetHorizontalMultiplier(UIElement element)
{
return (double)element.GetValue(HorizontalMultiplierProperty);
@ -68,6 +75,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Animations
/// </summary>
/// <param name="element">The target element for the attached property value.</param>
/// <param name="value">The value for how fast the parallax effect should scroll horizontally.</param>
[Obsolete("The ParallaxService will be removed in a future major release. Please use the ParallaxView control available in the Fall Creators Update")]
public static void SetHorizontalMultiplier(UIElement element, double value)
{
element.SetValue(HorizontalMultiplierProperty, value);

Просмотреть файл

@ -18,19 +18,69 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
public partial class Expander
{
/// <summary>
/// Key of the VisualStateGroup that open/close content
/// Key of the VisualStateGroup that trigger display mode (visible/collapsed/overlay) and direction content
/// </summary>
private const string ExpandedGroupStateContent = "ExpandedStates";
private const string DisplayModeAndDirectionStatesGroupStateContent = "DisplayModeAndDirectionStates";
/// <summary>
/// Key of the VisualState when content is expanded
/// Key of the VisualState when expander is visible and expander direction is set to Left
/// </summary>
private const string StateContentExpanded = "Expanded";
private const string StateContentVisibleLeft = "VisibleLeft";
/// <summary>
/// Key of the VisualState when content is collapsed
/// Key of the VisualState when expander is visible and expander direction is set to Down
/// </summary>
private const string StateContentCollapsed = "Collapsed";
private const string StateContentVisibleDown = "VisibleDown";
/// <summary>
/// Key of the VisualState when expander is visible and expander direction is set to Right
/// </summary>
private const string StateContentVisibleRight = "VisibleRight";
/// <summary>
/// Key of the VisualState when expander is visible and expander direction is set to Up
/// </summary>
private const string StateContentVisibleUp = "VisibleUp";
/// <summary>
/// Key of the VisualState when expander is collapsed and expander direction is set to Left
/// </summary>
private const string StateContentCollapsedLeft = "CollapsedLeft";
/// <summary>
/// Key of the VisualState when expander is collapsed and expander direction is set to Down
/// </summary>
private const string StateContentCollapsedDown = "CollapsedDown";
/// <summary>
/// Key of the VisualState when expander is collapsed and expander direction is set to Right
/// </summary>
private const string StateContentCollapsedRight = "CollapsedRight";
/// <summary>
/// Key of the VisualState when expander is collapsed and expander direction is set to Up
/// </summary>
private const string StateContentCollapsedUp = "CollapsedUp";
/// <summary>
/// Key of the VisualState when expander is overlay and expander direction is set to Left
/// </summary>
private const string StateContentOverlayLeft = "OverlayLeft";
/// <summary>
/// Key of the VisualState when expander is overlay and expander direction is set to Down
/// </summary>
private const string StateContentOverlayDown = "OverlayDown";
/// <summary>
/// Key of the VisualState when expander is overlay and expander direction is set to Right
/// </summary>
private const string StateContentOverlayRight = "OverlayRight";
/// <summary>
/// Key of the VisualState when expander is overlay and expander direction is set to Up
/// </summary>
private const string StateContentOverlayUp = "OverlayUp";
/// <summary>
/// Key of the UI Element that toggle IsExpanded property
@ -76,5 +126,10 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
/// Key of the UI Element that contains the content of the LayoutTransformer (of the expander button)
/// </summary>
private const string LayoutTransformerPart = "PART_LayoutTransformer";
/// <summary>
/// Key of the UI Element that contains the content of the control that is visible in Overlay mode
/// </summary>
private const string ContentOverlayPart = "PART_ContentOverlay";
}
}

Просмотреть файл

@ -43,6 +43,18 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
public static readonly DependencyProperty ExpandDirectionProperty =
DependencyProperty.Register(nameof(ExpandDirection), typeof(ExpandDirection), typeof(Expander), new PropertyMetadata(ExpandDirection.Down, OnExpandDirectionChanged));
/// <summary>
/// Identifies the <see cref="DisplayMode"/> dependency property.
/// </summary>
public static readonly DependencyProperty DisplayModeProperty =
DependencyProperty.Register(nameof(DisplayMode), typeof(ExpanderDisplayMode), typeof(Expander), new PropertyMetadata(ExpanderDisplayMode.Expand, OnDisplayModeChanged));
/// <summary>
/// Identifies the <see cref="ContentOverlay"/> dependency property.
/// </summary>
public static readonly DependencyProperty ContentOverlayProperty =
DependencyProperty.Register(nameof(ContentOverlay), typeof(UIElement), typeof(Expander), new PropertyMetadata(default(UIElement)));
/// <summary>
/// Gets or sets a value indicating whether the Header of the control.
/// </summary>
@ -79,6 +91,24 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
set { SetValue(ExpandDirectionProperty, value); }
}
/// <summary>
/// Gets or sets a value indicating whether the Expander control should be in Expand or Overlay mode.
/// </summary>
public ExpanderDisplayMode DisplayMode
{
get { return (ExpanderDisplayMode)GetValue(DisplayModeProperty); }
set { SetValue(DisplayModeProperty, value); }
}
/// <summary>
/// Gets or sets a value indicating whether the ContentOverlay of the control.
/// </summary>
public UIElement ContentOverlay
{
get { return (UIElement)GetValue(ContentOverlayProperty); }
set { SetValue(ContentOverlayProperty, value); }
}
private static void OnIsExpandedPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var expander = d as Expander;
@ -105,5 +135,17 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
expander.OnExpandDirectionChanged();
}
}
private static void OnDisplayModeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var expander = d as Expander;
var previousDisplayMode = (ExpanderDisplayMode)e.OldValue;
var newDisplayMode = (ExpanderDisplayMode)e.NewValue;
if (previousDisplayMode != newDisplayMode)
{
expander.OnDisplayModeOrIsExpandedChanged();
}
}
}
}

Просмотреть файл

@ -15,6 +15,7 @@ using Windows.System;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Markup;
namespace Microsoft.Toolkit.Uwp.UI.Controls
@ -22,15 +23,26 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
/// <summary>
/// The <see cref="Expander"/> control allows user to show/hide content based on a boolean state
/// </summary>
[TemplateVisualState(Name = StateContentExpanded, GroupName = ExpandedGroupStateContent)]
[TemplateVisualState(Name = StateContentCollapsed, GroupName = ExpandedGroupStateContent)]
[TemplateVisualState(Name = StateContentLeftDirection, GroupName = ExpandDirectionGroupStateContent)]
[TemplateVisualState(Name = StateContentDownDirection, GroupName = ExpandDirectionGroupStateContent)]
[TemplateVisualState(Name = StateContentRightDirection, GroupName = ExpandDirectionGroupStateContent)]
[TemplateVisualState(Name = StateContentUpDirection, GroupName = ExpandDirectionGroupStateContent)]
[TemplateVisualState(Name = StateContentVisibleLeft, GroupName = DisplayModeAndDirectionStatesGroupStateContent)]
[TemplateVisualState(Name = StateContentVisibleDown, GroupName = DisplayModeAndDirectionStatesGroupStateContent)]
[TemplateVisualState(Name = StateContentVisibleRight, GroupName = DisplayModeAndDirectionStatesGroupStateContent)]
[TemplateVisualState(Name = StateContentVisibleUp, GroupName = DisplayModeAndDirectionStatesGroupStateContent)]
[TemplateVisualState(Name = StateContentCollapsedLeft, GroupName = DisplayModeAndDirectionStatesGroupStateContent)]
[TemplateVisualState(Name = StateContentCollapsedDown, GroupName = DisplayModeAndDirectionStatesGroupStateContent)]
[TemplateVisualState(Name = StateContentCollapsedRight, GroupName = DisplayModeAndDirectionStatesGroupStateContent)]
[TemplateVisualState(Name = StateContentCollapsedUp, GroupName = DisplayModeAndDirectionStatesGroupStateContent)]
[TemplateVisualState(Name = StateContentOverlayLeft, GroupName = DisplayModeAndDirectionStatesGroupStateContent)]
[TemplateVisualState(Name = StateContentOverlayDown, GroupName = DisplayModeAndDirectionStatesGroupStateContent)]
[TemplateVisualState(Name = StateContentOverlayRight, GroupName = DisplayModeAndDirectionStatesGroupStateContent)]
[TemplateVisualState(Name = StateContentOverlayUp, GroupName = DisplayModeAndDirectionStatesGroupStateContent)]
[TemplatePart(Name = RootGridPart, Type = typeof(Grid))]
[TemplatePart(Name = ExpanderToggleButtonPart, Type = typeof(ToggleButton))]
[TemplatePart(Name = LayoutTransformerPart, Type = typeof(LayoutTransformControl))]
[TemplatePart(Name = ContentOverlayPart, Type = typeof(ContentPresenter))]
[ContentProperty(Name = "Content")]
public partial class Expander : ContentControl
{
@ -47,15 +59,6 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
{
base.OnApplyTemplate();
if (IsExpanded)
{
VisualStateManager.GoToState(this, StateContentExpanded, false);
}
else
{
VisualStateManager.GoToState(this, StateContentCollapsed, false);
}
var button = (ToggleButton)GetTemplateChild(ExpanderToggleButtonPart);
if (button != null)
@ -65,6 +68,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
}
OnExpandDirectionChanged();
OnDisplayModeOrIsExpandedChanged(false);
}
/// <summary>
@ -85,7 +89,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
Collapsed?.Invoke(this, args);
}
private void ExpanderToggleButtonPart_KeyDown(object sender, Windows.UI.Xaml.Input.KeyRoutedEventArgs e)
private void ExpanderToggleButtonPart_KeyDown(object sender, KeyRoutedEventArgs e)
{
if (e.Key != VirtualKey.Enter)
{
@ -106,20 +110,20 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
private void ExpandControl()
{
VisualStateManager.GoToState(this, StateContentExpanded, true);
OnDisplayModeOrIsExpandedChanged();
OnExpanded(EventArgs.Empty);
}
private void CollapseControl()
{
VisualStateManager.GoToState(this, StateContentCollapsed, true);
OnDisplayModeOrIsExpandedChanged();
OnCollapsed(EventArgs.Empty);
}
/// <summary>
/// Called when the ExpandDirection on Expander changes
/// </summary>
public void OnExpandDirectionChanged()
private void OnExpandDirectionChanged()
{
var button = (ToggleButton)GetTemplateChild(ExpanderToggleButtonPart);
@ -128,22 +132,20 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
return;
}
UpdateDisplayModeOrExpanderDirection();
switch (ExpandDirection)
{
case ExpandDirection.Left:
VisualStateManager.GoToState(this, StateContentLeftDirection, true);
VisualStateManager.GoToState(button, StateContentLeftDirection, true);
break;
case ExpandDirection.Down:
VisualStateManager.GoToState(this, StateContentDownDirection, true);
VisualStateManager.GoToState(button, StateContentDownDirection, true);
break;
case ExpandDirection.Right:
VisualStateManager.GoToState(this, StateContentRightDirection, true);
VisualStateManager.GoToState(button, StateContentRightDirection, true);
break;
case ExpandDirection.Up:
VisualStateManager.GoToState(this, StateContentUpDirection, true);
VisualStateManager.GoToState(button, StateContentUpDirection, true);
break;
}
@ -155,5 +157,54 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
VisualStateManager.GoToState(button, "Checked", true);
}
}
private void OnDisplayModeOrIsExpandedChanged(bool useTransitions = true)
{
UpdateDisplayModeOrExpanderDirection();
}
private void UpdateDisplayModeOrExpanderDirection()
{
string visualState = null;
switch (ExpandDirection)
{
case ExpandDirection.Left:
visualState = GetDisplayModeVisualState(StateContentOverlayLeft, StateContentCollapsedLeft, StateContentVisibleLeft);
break;
case ExpandDirection.Down:
visualState = GetDisplayModeVisualState(StateContentOverlayDown, StateContentCollapsedDown, StateContentVisibleDown);
break;
case ExpandDirection.Right:
visualState = GetDisplayModeVisualState(StateContentOverlayRight, StateContentCollapsedRight, StateContentVisibleRight);
break;
case ExpandDirection.Up:
visualState = GetDisplayModeVisualState(StateContentOverlayUp, StateContentCollapsedUp, StateContentVisibleUp);
break;
}
if (!string.IsNullOrWhiteSpace(visualState))
{
VisualStateManager.GoToState(this, visualState, true);
}
}
private string GetDisplayModeVisualState(string overlayState, string collapsedState, string visibleState)
{
if (!IsExpanded && DisplayMode == ExpanderDisplayMode.Overlay)
{
// Overlay
return overlayState;
}
if (!IsExpanded && DisplayMode == ExpanderDisplayMode.Expand)
{
// Collapsed
return collapsedState;
}
// Visible
return visibleState;
}
}
}

Просмотреть файл

@ -7,7 +7,7 @@
mc:Ignorable="d">
<Style x:Key="HeaderToggleButtonStyle" TargetType="ToggleButton">
<Setter Property="Background" Value="{ThemeResource SystemControlBackgroundBaseLowBrush}" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Foreground" Value="{ThemeResource SystemControlForegroundBaseHighBrush}" />
<Setter Property="BorderBrush" Value="{ThemeResource SystemControlForegroundTransparentBrush}" />
<Setter Property="BorderThickness" Value="{ThemeResource ToggleButtonBorderThemeThickness}" />
@ -323,42 +323,13 @@
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="controls:Expander">
<Grid>
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="ExpandedStates">
<VisualState x:Name="Expanded">
<VisualStateGroup x:Name="DisplayModeAndDirectionStates">
<VisualState x:Name="VisibleLeft">
<VisualState.Setters>
<Setter Target="PART_MainContent.Visibility" Value="Visible" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Collapsed">
<VisualState.Setters>
<Setter Target="PART_RootGrid.Background" Value="Transparent" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
<VisualStateGroup x:Name="ExpandDirectionStates">
<VisualState x:Name="RightDirection">
<VisualState.Setters>
<Setter Target="PART_LayoutTransformer.(Grid.Row)" Value="0" />
<Setter Target="PART_LayoutTransformer.(Grid.RowSpan)" Value="2" />
<Setter Target="PART_LayoutTransformer.(Grid.Column)" Value="0" />
<Setter Target="PART_LayoutTransformer.(Grid.ColumnSpan)" Value="1" />
<Setter Target="PART_MainContent.(Grid.Row)" Value="0" />
<Setter Target="PART_MainContent.(Grid.RowSpan)" Value="2" />
<Setter Target="PART_MainContent.(Grid.Column)" Value="1" />
<Setter Target="PART_MainContent.(Grid.ColumnSpan)" Value="1" />
<Setter Target="RotateLayoutTransform.Angle" Value="-90" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="DownDirection" />
<VisualState x:Name="LeftDirection">
<VisualState.Setters>
<Setter Target="PART_LayoutTransformer.(Grid.Row)" Value="0" />
<Setter Target="PART_LayoutTransformer.(Grid.RowSpan)" Value="2" />
<Setter Target="PART_LayoutTransformer.(Grid.Column)" Value="1" />
@ -369,15 +340,86 @@
<Setter Target="PART_MainContent.(Grid.Column)" Value="0" />
<Setter Target="PART_MainContent.(Grid.ColumnSpan)" Value="1" />
<Setter Target="PART_ContentOverlay.(Grid.Row)" Value="0" />
<Setter Target="PART_ContentOverlay.(Grid.RowSpan)" Value="2" />
<Setter Target="PART_ContentOverlay.(Grid.Column)" Value="0" />
<Setter Target="PART_ContentOverlay.(Grid.ColumnSpan)" Value="1" />
<Setter Target="RotateLayoutTransform.Angle" Value="-90" />
<Setter Target="ColumnOne.Width" Value="*" />
<Setter Target="ColumnTwo.Width" Value="Auto" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="UpDirection">
<Setter Target="PART_MainContent.RenderTransformOrigin" Value="1,0" />
</VisualState.Setters>
<Storyboard>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="PART_MainContent">
<EasingDoubleKeyFrame KeyTime="0" Value="0"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="0"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="1"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleX)" Storyboard.TargetName="PART_MainContent">
<EasingDoubleKeyFrame KeyTime="0" Value="0"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="1"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="VisibleDown">
<VisualState.Setters>
<Setter Target="PART_MainContent.Visibility" Value="Visible" />
</VisualState.Setters>
<Storyboard>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="PART_MainContent">
<EasingDoubleKeyFrame KeyTime="0" Value="0"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="0"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="1"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleY)" Storyboard.TargetName="PART_MainContent">
<EasingDoubleKeyFrame KeyTime="0" Value="0"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="1"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="VisibleRight">
<VisualState.Setters>
<Setter Target="PART_MainContent.Visibility" Value="Visible" />
<Setter Target="PART_LayoutTransformer.(Grid.Row)" Value="0" />
<Setter Target="PART_LayoutTransformer.(Grid.RowSpan)" Value="2" />
<Setter Target="PART_LayoutTransformer.(Grid.Column)" Value="0" />
<Setter Target="PART_LayoutTransformer.(Grid.ColumnSpan)" Value="1" />
<Setter Target="PART_MainContent.(Grid.Row)" Value="0" />
<Setter Target="PART_MainContent.(Grid.RowSpan)" Value="2" />
<Setter Target="PART_MainContent.(Grid.Column)" Value="1" />
<Setter Target="PART_MainContent.(Grid.ColumnSpan)" Value="1" />
<Setter Target="PART_ContentOverlay.(Grid.Row)" Value="0" />
<Setter Target="PART_ContentOverlay.(Grid.RowSpan)" Value="2" />
<Setter Target="PART_ContentOverlay.(Grid.Column)" Value="1" />
<Setter Target="PART_ContentOverlay.(Grid.ColumnSpan)" Value="1" />
<Setter Target="RotateLayoutTransform.Angle" Value="-90" />
</VisualState.Setters>
<Storyboard>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="PART_MainContent">
<EasingDoubleKeyFrame KeyTime="0" Value="0"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="0"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="1"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleX)" Storyboard.TargetName="PART_MainContent">
<EasingDoubleKeyFrame KeyTime="0" Value="0"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="1"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="VisibleUp">
<VisualState.Setters>
<Setter Target="PART_MainContent.Visibility" Value="Visible" />
<Setter Target="PART_LayoutTransformer.(Grid.Row)" Value="1" />
<Setter Target="PART_LayoutTransformer.(Grid.RowSpan)" Value="1" />
<Setter Target="PART_LayoutTransformer.(Grid.Column)" Value="0" />
@ -388,13 +430,237 @@
<Setter Target="PART_MainContent.(Grid.Column)" Value="0" />
<Setter Target="PART_MainContent.(Grid.ColumnSpan)" Value="2" />
<Setter Target="PART_ContentOverlay.(Grid.Row)" Value="0" />
<Setter Target="PART_ContentOverlay.(Grid.RowSpan)" Value="1" />
<Setter Target="PART_ContentOverlay.(Grid.Column)" Value="0" />
<Setter Target="PART_ContentOverlay.(Grid.ColumnSpan)" Value="2" />
<Setter Target="RotateLayoutTransform.Angle" Value="0" />
<Setter Target="PART_MainContent.RenderTransformOrigin" Value="0,1" />
</VisualState.Setters>
<Storyboard>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="PART_MainContent">
<EasingDoubleKeyFrame KeyTime="0" Value="0"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="0"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="1"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleY)" Storyboard.TargetName="PART_MainContent">
<EasingDoubleKeyFrame KeyTime="0" Value="0"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="1"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="CollapsedLeft">
<VisualState.Setters>
<Setter Target="PART_RootGrid.Background" Value="Transparent" />
<Setter Target="PART_LayoutTransformer.(Grid.Row)" Value="0" />
<Setter Target="PART_LayoutTransformer.(Grid.RowSpan)" Value="2" />
<Setter Target="PART_LayoutTransformer.(Grid.Column)" Value="1" />
<Setter Target="PART_LayoutTransformer.(Grid.ColumnSpan)" Value="1" />
<Setter Target="PART_MainContent.(Grid.Row)" Value="0" />
<Setter Target="PART_MainContent.(Grid.RowSpan)" Value="2" />
<Setter Target="PART_MainContent.(Grid.Column)" Value="0" />
<Setter Target="PART_MainContent.(Grid.ColumnSpan)" Value="1" />
<Setter Target="PART_ContentOverlay.(Grid.Row)" Value="0" />
<Setter Target="PART_ContentOverlay.(Grid.RowSpan)" Value="2" />
<Setter Target="PART_ContentOverlay.(Grid.Column)" Value="0" />
<Setter Target="PART_ContentOverlay.(Grid.ColumnSpan)" Value="1" />
<Setter Target="RotateLayoutTransform.Angle" Value="-90" />
<Setter Target="ColumnOne.Width" Value="*" />
<Setter Target="ColumnTwo.Width" Value="Auto" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="CollapsedDown">
<VisualState.Setters>
<Setter Target="PART_RootGrid.Background" Value="Transparent" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="CollapsedRight">
<VisualState.Setters>
<Setter Target="PART_RootGrid.Background" Value="Transparent" />
<Setter Target="PART_LayoutTransformer.(Grid.Row)" Value="0" />
<Setter Target="PART_LayoutTransformer.(Grid.RowSpan)" Value="2" />
<Setter Target="PART_LayoutTransformer.(Grid.Column)" Value="0" />
<Setter Target="PART_LayoutTransformer.(Grid.ColumnSpan)" Value="1" />
<Setter Target="PART_MainContent.(Grid.Row)" Value="0" />
<Setter Target="PART_MainContent.(Grid.RowSpan)" Value="2" />
<Setter Target="PART_MainContent.(Grid.Column)" Value="1" />
<Setter Target="PART_MainContent.(Grid.ColumnSpan)" Value="1" />
<Setter Target="PART_ContentOverlay.(Grid.Row)" Value="0" />
<Setter Target="PART_ContentOverlay.(Grid.RowSpan)" Value="2" />
<Setter Target="PART_ContentOverlay.(Grid.Column)" Value="1" />
<Setter Target="PART_ContentOverlay.(Grid.ColumnSpan)" Value="1" />
<Setter Target="RotateLayoutTransform.Angle" Value="-90" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="CollapsedUp">
<VisualState.Setters>
<Setter Target="PART_RootGrid.Background" Value="Transparent" />
<Setter Target="PART_LayoutTransformer.(Grid.Row)" Value="1" />
<Setter Target="PART_LayoutTransformer.(Grid.RowSpan)" Value="1" />
<Setter Target="PART_LayoutTransformer.(Grid.Column)" Value="0" />
<Setter Target="PART_LayoutTransformer.(Grid.ColumnSpan)" Value="2" />
<Setter Target="PART_MainContent.(Grid.Row)" Value="0" />
<Setter Target="PART_MainContent.(Grid.RowSpan)" Value="1" />
<Setter Target="PART_MainContent.(Grid.Column)" Value="0" />
<Setter Target="PART_MainContent.(Grid.ColumnSpan)" Value="2" />
<Setter Target="PART_ContentOverlay.(Grid.Row)" Value="0" />
<Setter Target="PART_ContentOverlay.(Grid.RowSpan)" Value="1" />
<Setter Target="PART_ContentOverlay.(Grid.Column)" Value="0" />
<Setter Target="PART_ContentOverlay.(Grid.ColumnSpan)" Value="2" />
<Setter Target="RotateLayoutTransform.Angle" Value="0" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="OverlayLeft">
<VisualState.Setters>
<Setter Target="PART_MainContent.Visibility" Value="Visible" />
<Setter Target="PART_ContentOverlay.Visibility" Value="Visible" />
<Setter Target="PART_LayoutTransformer.(Grid.Row)" Value="0" />
<Setter Target="PART_LayoutTransformer.(Grid.RowSpan)" Value="2" />
<Setter Target="PART_LayoutTransformer.(Grid.Column)" Value="1" />
<Setter Target="PART_LayoutTransformer.(Grid.ColumnSpan)" Value="1" />
<Setter Target="PART_MainContent.(Grid.Row)" Value="0" />
<Setter Target="PART_MainContent.(Grid.RowSpan)" Value="2" />
<Setter Target="PART_MainContent.(Grid.Column)" Value="0" />
<Setter Target="PART_MainContent.(Grid.ColumnSpan)" Value="1" />
<Setter Target="PART_ContentOverlay.(Grid.Row)" Value="0" />
<Setter Target="PART_ContentOverlay.(Grid.RowSpan)" Value="2" />
<Setter Target="PART_ContentOverlay.(Grid.Column)" Value="0" />
<Setter Target="PART_ContentOverlay.(Grid.ColumnSpan)" Value="1" />
<Setter Target="RotateLayoutTransform.Angle" Value="-90" />
<Setter Target="ColumnOne.Width" Value="*" />
<Setter Target="ColumnTwo.Width" Value="Auto" />
<Setter Target="PART_ContentOverlay.RenderTransformOrigin" Value="0,1" />
</VisualState.Setters>
<Storyboard>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="PART_MainContent">
<EasingDoubleKeyFrame KeyTime="0" Value="1"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="0"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleX)" Storyboard.TargetName="PART_ContentOverlay">
<EasingDoubleKeyFrame KeyTime="0" Value="0"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="1"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="OverlayDown">
<VisualState.Setters>
<Setter Target="PART_MainContent.Visibility" Value="Visible" />
<Setter Target="PART_ContentOverlay.Visibility" Value="Visible" />
<Setter Target="PART_ContentOverlay.RenderTransformOrigin" Value="0,1" />
</VisualState.Setters>
<Storyboard>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="PART_MainContent">
<EasingDoubleKeyFrame KeyTime="0" Value="1"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="0"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleY)" Storyboard.TargetName="PART_ContentOverlay">
<EasingDoubleKeyFrame KeyTime="0" Value="0"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="1"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="OverlayRight">
<VisualState.Setters>
<Setter Target="PART_MainContent.Visibility" Value="Visible" />
<Setter Target="PART_ContentOverlay.Visibility" Value="Visible" />
<Setter Target="PART_LayoutTransformer.(Grid.Row)" Value="0" />
<Setter Target="PART_LayoutTransformer.(Grid.RowSpan)" Value="2" />
<Setter Target="PART_LayoutTransformer.(Grid.Column)" Value="0" />
<Setter Target="PART_LayoutTransformer.(Grid.ColumnSpan)" Value="1" />
<Setter Target="PART_MainContent.(Grid.Row)" Value="0" />
<Setter Target="PART_MainContent.(Grid.RowSpan)" Value="2" />
<Setter Target="PART_MainContent.(Grid.Column)" Value="1" />
<Setter Target="PART_MainContent.(Grid.ColumnSpan)" Value="1" />
<Setter Target="PART_ContentOverlay.(Grid.Row)" Value="0" />
<Setter Target="PART_ContentOverlay.(Grid.RowSpan)" Value="2" />
<Setter Target="PART_ContentOverlay.(Grid.Column)" Value="1" />
<Setter Target="PART_ContentOverlay.(Grid.ColumnSpan)" Value="1" />
<Setter Target="RotateLayoutTransform.Angle" Value="-90" />
<Setter Target="PART_ContentOverlay.RenderTransformOrigin" Value="1,0" />
</VisualState.Setters>
<Storyboard>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="PART_MainContent">
<EasingDoubleKeyFrame KeyTime="0" Value="1"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="0"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleX)" Storyboard.TargetName="PART_ContentOverlay">
<EasingDoubleKeyFrame KeyTime="0" Value="0"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="1"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="OverlayUp">
<VisualState.Setters>
<Setter Target="PART_MainContent.Visibility" Value="Visible" />
<Setter Target="PART_MainContent.Opacity" Value="0" />
<Setter Target="PART_ContentOverlay.Visibility" Value="Visible" />
<Setter Target="PART_LayoutTransformer.(Grid.Row)" Value="1" />
<Setter Target="PART_LayoutTransformer.(Grid.RowSpan)" Value="1" />
<Setter Target="PART_LayoutTransformer.(Grid.Column)" Value="0" />
<Setter Target="PART_LayoutTransformer.(Grid.ColumnSpan)" Value="2" />
<Setter Target="PART_MainContent.(Grid.Row)" Value="0" />
<Setter Target="PART_MainContent.(Grid.RowSpan)" Value="1" />
<Setter Target="PART_MainContent.(Grid.Column)" Value="0" />
<Setter Target="PART_MainContent.(Grid.ColumnSpan)" Value="2" />
<Setter Target="PART_ContentOverlay.(Grid.Row)" Value="0" />
<Setter Target="PART_ContentOverlay.(Grid.RowSpan)" Value="1" />
<Setter Target="PART_ContentOverlay.(Grid.Column)" Value="0" />
<Setter Target="PART_ContentOverlay.(Grid.ColumnSpan)" Value="2" />
<Setter Target="RotateLayoutTransform.Angle" Value="0" />
</VisualState.Setters>
<Storyboard>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="PART_MainContent">
<EasingDoubleKeyFrame KeyTime="0" Value="1"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.2" Value="0"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.ScaleY)" Storyboard.TargetName="PART_ContentOverlay">
<EasingDoubleKeyFrame KeyTime="0" Value="0"/>
<EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="1"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Grid x:Name="PART_RootGrid" Background="{TemplateBinding Background}">
<Grid x:Name="PART_RootGrid">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
@ -419,20 +685,36 @@
Style="{StaticResource HeaderToggleButtonStyle}"
VerticalAlignment="Bottom" HorizontalAlignment="Stretch"
Foreground="{TemplateBinding Foreground}"
Background="{TemplateBinding Background}"
ContentTemplate="{TemplateBinding HeaderTemplate}" Content="{TemplateBinding Header}"
IsChecked="{Binding IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" />
</controls:LayoutTransformControl>
<ContentControl Grid.Row="1" Grid.RowSpan="1" Grid.Column="0" Grid.ColumnSpan="2"
x:Name="PART_ContentOverlay"
Content="{TemplateBinding ContentOverlay}"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Stretch"
VerticalAlignment="Stretch"
VerticalContentAlignment="Stretch"
Visibility="Collapsed">
<ContentControl.RenderTransform>
<ScaleTransform />
</ContentControl.RenderTransform>
</ContentControl>
<ContentPresenter Grid.Row="1" Grid.RowSpan="1" Grid.Column="0" Grid.ColumnSpan="2"
x:Name="PART_MainContent"
Background="{TemplateBinding Background}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
HorizontalContentAlignment="Stretch"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Visibility="Collapsed" />
VerticalContentAlignment="Stretch"
Visibility="Collapsed">
<ContentPresenter.RenderTransform>
<ScaleTransform />
</ContentPresenter.RenderTransform>
</ContentPresenter>
</Grid>
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>

Просмотреть файл

@ -0,0 +1,30 @@
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
namespace Microsoft.Toolkit.Uwp.UI.Controls
{
/// <summary>
/// Display mode of the Expander that will update the behavior of the content visibility
/// </summary>
public enum ExpanderDisplayMode
{
/// <summary>
/// Default mode (the content is totally collapsed)
/// </summary>
Expand,
/// <summary>
/// Overlay mode (only the overlay content is visible)
/// </summary>
Overlay
}
}

Просмотреть файл

@ -10,6 +10,9 @@
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
using System;
using System.Collections.Generic;
using System.Linq;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
@ -30,6 +33,11 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
/// </summary>
public event ItemClickEventHandler OptionsItemClick;
/// <summary>
/// Event raised when an item is invoked
/// </summary>
public event EventHandler<HamburgetMenuItemInvokedEventArgs> ItemInvoked;
private void HamburgerButton_Click(object sender, RoutedEventArgs e)
{
IsPaneOpen = !IsPaneOpen;
@ -43,6 +51,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
}
ItemClick?.Invoke(this, e);
ItemInvoked?.Invoke(this, new HamburgetMenuItemInvokedEventArgs() { InvokedItem = e.ClickedItem, IsItemOptions = false });
}
private void OptionsListView_ItemClick(object sender, ItemClickEventArgs e)
@ -53,6 +62,15 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
}
OptionsItemClick?.Invoke(this, e);
ItemInvoked?.Invoke(this, new HamburgetMenuItemInvokedEventArgs() { InvokedItem = e.ClickedItem, IsItemOptions = true });
}
private void NavigationViewItemInvoked(NavigationView sender, NavigationViewItemInvokedEventArgs args)
{
var options = OptionsItemsSource as IEnumerable<object>;
var isOption = options != null && options.Contains(args.InvokedItem);
ItemInvoked?.Invoke(this, new HamburgetMenuItemInvokedEventArgs() { InvokedItem = args.InvokedItem, IsItemOptions = isOption });
}
}
}

Просмотреть файл

@ -24,7 +24,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
/// <summary>
/// Identifies the <see cref="OptionsItemsSource"/> dependency property.
/// </summary>
public static readonly DependencyProperty OptionsItemsSourceProperty = DependencyProperty.Register(nameof(OptionsItemsSource), typeof(object), typeof(HamburgerMenu), new PropertyMetadata(null));
public static readonly DependencyProperty OptionsItemsSourceProperty = DependencyProperty.Register(nameof(OptionsItemsSource), typeof(object), typeof(HamburgerMenu), new PropertyMetadata(null, OnItemsSourceChanged));
/// <summary>
/// Identifies the <see cref="OptionsItemTemplate"/> dependency property.
@ -44,12 +44,12 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
/// <summary>
/// Identifies the <see cref="SelectedOptionsItem"/> dependency property.
/// </summary>
public static readonly DependencyProperty SelectedOptionsItemProperty = DependencyProperty.Register(nameof(SelectedOptionsItem), typeof(object), typeof(HamburgerMenu), new PropertyMetadata(null));
public static readonly DependencyProperty SelectedOptionsItemProperty = DependencyProperty.Register(nameof(SelectedOptionsItem), typeof(object), typeof(HamburgerMenu), new PropertyMetadata(null, OnSelectedItemChanged));
/// <summary>
/// Identifies the <see cref="SelectedOptionsIndex"/> dependency property.
/// </summary>
public static readonly DependencyProperty SelectedOptionsIndexProperty = DependencyProperty.Register(nameof(SelectedOptionsIndex), typeof(int), typeof(HamburgerMenu), new PropertyMetadata(-1));
public static readonly DependencyProperty SelectedOptionsIndexProperty = DependencyProperty.Register(nameof(SelectedOptionsIndex), typeof(int), typeof(HamburgerMenu), new PropertyMetadata(-1, OnSelectedOptionsIndexChanged));
/// <summary>
/// Gets or sets an object source used to generate the content of the options.

Просмотреть файл

@ -11,6 +11,8 @@
// ******************************************************************
using System;
using System.Collections.Generic;
using System.Linq;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Media;
@ -60,7 +62,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
/// <summary>
/// Identifies the <see cref="ItemsSource"/> dependency property.
/// </summary>
public static readonly DependencyProperty ItemsSourceProperty = DependencyProperty.Register(nameof(ItemsSource), typeof(object), typeof(HamburgerMenu), new PropertyMetadata(null));
public static readonly DependencyProperty ItemsSourceProperty = DependencyProperty.Register(nameof(ItemsSource), typeof(object), typeof(HamburgerMenu), new PropertyMetadata(null, OnItemsSourceChanged));
/// <summary>
/// Identifies the <see cref="ItemTemplate"/> dependency property.
@ -75,12 +77,18 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
/// <summary>
/// Identifies the <see cref="SelectedItem"/> dependency property.
/// </summary>
public static readonly DependencyProperty SelectedItemProperty = DependencyProperty.Register(nameof(SelectedItem), typeof(object), typeof(HamburgerMenu), new PropertyMetadata(null));
public static readonly DependencyProperty SelectedItemProperty = DependencyProperty.Register(nameof(SelectedItem), typeof(object), typeof(HamburgerMenu), new PropertyMetadata(null, OnSelectedItemChanged));
/// <summary>
/// Identifies the <see cref="SelectedIndex"/> dependency property.
/// </summary>
public static readonly DependencyProperty SelectedIndexProperty = DependencyProperty.Register(nameof(SelectedIndex), typeof(int), typeof(HamburgerMenu), new PropertyMetadata(-1));
public static readonly DependencyProperty SelectedIndexProperty = DependencyProperty.Register(nameof(SelectedIndex), typeof(int), typeof(HamburgerMenu), new PropertyMetadata(-1, OnSelectedIndexChanged));
/// <summary>
/// Identifies the <see cref="UseNavigationViewWhenPossible"/> dependency property
/// </summary>
public static readonly DependencyProperty UseNavigationViewWhenPossibleProperty =
DependencyProperty.Register("UseNavigationViewWhenPossible", typeof(bool), typeof(HamburgerMenu), new PropertyMetadata(false, OnUseNavigationViewWhenPossibleChanged));
/// <summary>
/// Gets or sets the width of the pane when it's fully expanded.
@ -209,5 +217,77 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
get { return (int)GetValue(SelectedIndexProperty); }
set { SetValue(SelectedIndexProperty, value); }
}
/// <summary>
/// Gets or sets a value indicating whether the HamburgerMenu should use the NavigationView when possible (Fall Creators Update and above)
/// When set to true and the device supports NavigationView, the HamburgerMenu will use a template based on NavigationView
/// </summary>
public bool UseNavigationViewWhenPossible
{
get { return (bool)GetValue(UseNavigationViewWhenPossibleProperty); }
set { SetValue(UseNavigationViewWhenPossibleProperty, value); }
}
private static void OnItemsSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is HamburgerMenu hamburgerMenu && hamburgerMenu.UsingNavView)
{
hamburgerMenu.NavViewSetItemsSource();
}
}
private static void OnUseNavigationViewWhenPossibleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var menu = d as HamburgerMenu;
if (menu == null)
{
return;
}
if (menu.UseNavigationViewWhenPossible && HamburgerMenu.IsNavigationViewSupported)
{
ResourceDictionary dict = new ResourceDictionary();
dict.Source = new System.Uri("ms-appx:///Microsoft.Toolkit.Uwp.UI.Controls/HamburgerMenu/HamburgerMenuNavViewTemplate.xaml");
menu._previousTemplateUsed = menu.Template;
menu.Template = dict["HamburgerMenuNavViewTemplate"] as ControlTemplate;
}
else if (!menu.UseNavigationViewWhenPossible &&
e.OldValue is bool oldValue &&
oldValue &&
menu._previousTemplateUsed != null)
{
menu.Template = menu._previousTemplateUsed;
}
}
private static void OnSelectedItemChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is HamburgerMenu menu && menu.UsingNavView)
{
menu.NavViewSetSelectedItem(e.NewValue);
}
}
private static void OnSelectedIndexChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is HamburgerMenu menu && menu.UsingNavView)
{
if (menu.ItemsSource is IEnumerable<object> items)
{
menu.NavViewSetSelectedItem((int)e.NewValue >= 0 ? items.ElementAt((int)e.NewValue) : null);
}
}
}
private static void OnSelectedOptionsIndexChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is HamburgerMenu menu && menu.UsingNavView)
{
if (menu.ItemsSource is IEnumerable<object> options)
{
menu.NavViewSetSelectedItem((int)e.NewValue >= 0 ? options.ElementAt((int)e.NewValue) : null);
}
}
}
}
}

Просмотреть файл

@ -10,8 +10,14 @@
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Toolkit.Uwp.UI.Extensions;
using Windows.Foundation.Metadata;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Data;
namespace Microsoft.Toolkit.Uwp.UI.Controls
{
@ -19,13 +25,24 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
/// The HamburgerMenu is based on a SplitView control. By default it contains a HamburgerButton and a ListView to display menu items.
/// </summary>
[TemplatePart(Name = "HamburgerButton", Type = typeof(Button))]
[TemplatePart(Name = "ButtonsListView", Type = typeof(ListViewBase))]
[TemplatePart(Name = "OptionsListView", Type = typeof(ListViewBase))]
[TemplatePart(Name = "ButtonsListView", Type = typeof(Windows.UI.Xaml.Controls.ListViewBase))]
[TemplatePart(Name = "OptionsListView", Type = typeof(Windows.UI.Xaml.Controls.ListViewBase))]
[Obsolete("The HamburgerMenu will be removed in a future major release. Please use the NavigationView control available in the Fall Creators Update")]
public partial class HamburgerMenu : ContentControl
{
private Button _hamburgerButton;
private ListViewBase _buttonsListView;
private ListViewBase _optionsListView;
private Windows.UI.Xaml.Controls.ListViewBase _buttonsListView;
private Windows.UI.Xaml.Controls.ListViewBase _optionsListView;
private ControlTemplate _previousTemplateUsed;
private object _navigationView;
private bool UsingNavView => UseNavigationViewWhenPossible && IsNavigationViewSupported;
/// <summary>
/// Gets a value indicating whether <see cref="NavigationView"/> is supported
/// </summary>
public static bool IsNavigationViewSupported { get; } = ApiInformation.IsTypePresent("Windows.UI.Xaml.Controls.NavigationView");
/// <summary>
/// Initializes a new instance of the <see cref="HamburgerMenu"/> class.
@ -60,9 +77,14 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
_optionsListView.ItemClick -= OptionsListView_ItemClick;
}
if (UsingNavView)
{
OnApplyTemplateNavView();
}
_hamburgerButton = (Button)GetTemplateChild("HamburgerButton");
_buttonsListView = (ListViewBase)GetTemplateChild("ButtonsListView");
_optionsListView = (ListViewBase)GetTemplateChild("OptionsListView");
_buttonsListView = (Windows.UI.Xaml.Controls.ListViewBase)GetTemplateChild("ButtonsListView");
_optionsListView = (Windows.UI.Xaml.Controls.ListViewBase)GetTemplateChild("OptionsListView");
if (_hamburgerButton != null)
{
@ -81,5 +103,155 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
base.OnApplyTemplate();
}
private void OnApplyTemplateNavView()
{
if (_navigationView is NavigationView navView)
{
navView.ItemInvoked -= NavigationViewItemInvoked;
navView.SelectionChanged -= NavigationViewSelectionChanged;
navView.Loaded -= NavigationViewLoaded;
}
navView = GetTemplateChild("NavView") as NavigationView;
if (navView != null)
{
navView.ItemInvoked += NavigationViewItemInvoked;
navView.SelectionChanged += NavigationViewSelectionChanged;
navView.Loaded += NavigationViewLoaded;
navView.MenuItemTemplateSelector = new HamburgerMenuNavViewItemTemplateSelector(this);
_navigationView = navView;
OnItemsSourceChanged(this, null);
}
}
private void NavViewSetItemsSource()
{
if (UsingNavView && _navigationView is NavigationView navView && navView != null)
{
var items = ItemsSource as IEnumerable<object>;
var options = OptionsItemsSource as IEnumerable<object>;
List<object> combined = new List<object>();
if (items != null)
{
foreach (var item in items)
{
combined.Add(item);
}
}
if (options != null)
{
if (options.Count() > 0)
{
combined.Add(new NavigationViewItemSeparator());
}
foreach (var option in options)
{
combined.Add(option);
}
}
navView.MenuItemsSource = combined;
}
}
private void NavViewSetSelectedItem(object item)
{
if (UsingNavView && _navigationView is NavigationView navView)
{
navView.SelectedItem = item;
}
}
private void NavigationViewLoaded(object sender, RoutedEventArgs e)
{
var navView = sender as NavigationView;
if (navView == null)
{
return;
}
navView.Loaded -= NavigationViewLoaded;
if (navView.FindDescendantByName("TogglePaneButton") is Button hamburgerButton)
{
var templateBinding = new Binding()
{
Source = this,
Path = new PropertyPath(nameof(HamburgerMenuTemplate)),
Mode = BindingMode.OneWay
};
var heightBinding = new Binding()
{
Source = this,
Path = new PropertyPath(nameof(HamburgerHeight)),
Mode = BindingMode.OneWay
};
var widthBinding = new Binding()
{
Source = this,
Path = new PropertyPath(nameof(HamburgerWidth)),
Mode = BindingMode.OneWay
};
var marginBinding = new Binding()
{
Source = this,
Path = new PropertyPath(nameof(HamburgerMargin)),
Mode = BindingMode.OneWay
};
var foregroundMargin = new Binding()
{
Source = this,
Path = new PropertyPath(nameof(PaneForeground)),
Mode = BindingMode.OneWay
};
hamburgerButton.SetBinding(Button.ContentTemplateProperty, templateBinding);
hamburgerButton.SetBinding(Button.HeightProperty, heightBinding);
hamburgerButton.SetBinding(Button.WidthProperty, widthBinding);
hamburgerButton.SetBinding(Button.MarginProperty, marginBinding);
hamburgerButton.SetBinding(Button.ForegroundProperty, foregroundMargin);
}
}
private void NavigationViewSelectionChanged(NavigationView sender, NavigationViewSelectionChangedEventArgs args)
{
if (args.IsSettingsSelected)
{
SelectedItem = null;
SelectedIndex = -1;
SelectedOptionsItem = null;
SelectedOptionsIndex = -1;
}
else if (args.SelectedItem != null)
{
var items = ItemsSource as IEnumerable<object>;
var options = OptionsItemsSource as IEnumerable<object>;
if (items != null && items.Contains(args.SelectedItem))
{
SelectedItem = args.SelectedItem;
SelectedIndex = items.ToList().IndexOf(SelectedItem);
SelectedOptionsItem = null;
SelectedOptionsIndex = -1;
}
else if (options != null && options.Contains(args.SelectedItem))
{
SelectedItem = null;
SelectedIndex = -1;
SelectedOptionsItem = args.SelectedItem;
SelectedOptionsIndex = options.ToList().IndexOf(SelectedItem);
}
}
}
}
}

Просмотреть файл

@ -2,86 +2,9 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Microsoft.Toolkit.Uwp.UI.Controls">
<Style x:Key="HambugerMenuItemStyle" TargetType="ListViewItem">
<Setter Property="Foreground" Value="{ThemeResource SystemControlForegroundBaseHighBrush}" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="MinHeight" Value="0"/>
<Setter Property="Padding" Value="0"/>
<Setter Property="UseSystemFocusVisuals" Value="True" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="VerticalContentAlignment" Value="Stretch" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListViewItem">
<Grid x:Name="LayoutRoot"
Background="{TemplateBinding Background}"
Control.IsTemplateFocusTarget="True"
Height="40">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="PointerStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="PointerOver">
<VisualState.Setters>
<Setter Target="LayoutRoot.Background" Value="{ThemeResource SystemControlHighlightListLowBrush}" />
<Setter Target="ContentPresenter.Foreground" Value="{ThemeResource SystemControlHighlightAltBaseHighBrush}" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Pressed">
<VisualState.Setters>
<Setter Target="LayoutRoot.Background" Value="{ThemeResource SystemControlHighlightListMediumBrush}" />
<Setter Target="ContentPresenter.Foreground" Value="{ThemeResource SystemControlHighlightAltBaseHighBrush}" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Selected">
<VisualState.Setters>
<Setter Target="SelectionIndicator.Opacity" Value="1.0" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="PointerOverSelected">
<VisualState.Setters>
<Setter Target="LayoutRoot.Background" Value="{ThemeResource SystemControlHighlightListLowBrush}" />
<Setter Target="ContentPresenter.Foreground" Value="{ThemeResource SystemControlHighlightAltBaseHighBrush}" />
<Setter Target="SelectionIndicator.Opacity" Value="1.0" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="PressedSelected">
<VisualState.Setters>
<Setter Target="LayoutRoot.Background" Value="{ThemeResource SystemControlHighlightListMediumBrush}" />
<Setter Target="ContentPresenter.Foreground" Value="{ThemeResource SystemControlHighlightAltBaseHighBrush}" />
<Setter Target="SelectionIndicator.Opacity" Value="1.0" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
<VisualStateGroup x:Name="DisabledStates">
<VisualState x:Name="Enabled" />
<VisualState x:Name="Disabled">
<VisualState.Setters>
<Setter Target="LayoutRoot.Opacity" Value="{ThemeResource ListViewItemDisabledThemeOpacity}" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<!-- Wrap SelectionIndicator in a grid so that its offset is 0,0 - this enables the offset animation. -->
<Grid HorizontalAlignment="Left" VerticalAlignment="Center">
<Rectangle x:Name="SelectionIndicator"
Fill="{ThemeResource SystemControlForegroundAccentBrush}"
Height="24"
Opacity="0.0"
Width="6"/>
</Grid>
<ContentPresenter x:Name="ContentPresenter"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
ContentTransitions="{TemplateBinding ContentTransitions}"
Grid.Column="1"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
Margin="{TemplateBinding Padding}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="ms-appx:///Microsoft.Toolkit.Uwp.UI.Controls/HamburgerMenu/HamburgerMenuTemplate.xaml" />
</ResourceDictionary.MergedDictionaries>
<Style TargetType="local:HamburgerMenu">
<Setter Property="HamburgerMenuTemplate">
@ -94,86 +17,7 @@
</Setter.Value>
</Setter>
<Setter Property="IsTabStop" Value="False" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="local:HamburgerMenu">
<Grid>
<SplitView x:Name="MainSplitView"
CompactPaneLength="{TemplateBinding CompactPaneLength}"
DisplayMode="{TemplateBinding DisplayMode}"
IsPaneOpen="{Binding IsPaneOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
IsTabStop="False"
OpenPaneLength="{TemplateBinding OpenPaneLength}"
PaneBackground="{TemplateBinding PaneBackground}"
PanePlacement="{TemplateBinding PanePlacement}">
<SplitView.Pane>
<Grid x:Name="PaneGrid"
FlowDirection="LeftToRight">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid Grid.Row="0"
Height="{TemplateBinding HamburgerHeight}"
Margin="0,0,0,8" />
<ListView x:Name="ButtonsListView"
Grid.Row="1"
Width="{TemplateBinding OpenPaneLength}"
AutomationProperties.Name="Menu items"
IsItemClickEnabled="True"
ItemContainerStyle="{StaticResource HambugerMenuItemStyle}"
ItemTemplate="{TemplateBinding ItemTemplate}"
ItemTemplateSelector="{TemplateBinding ItemTemplateSelector}"
ItemsSource="{TemplateBinding ItemsSource}"
ScrollViewer.VerticalScrollBarVisibility="Auto"
SelectedIndex="{Binding SelectedIndex, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
SelectedItem="{Binding SelectedItem, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
SelectionMode="Single"
TabIndex="1">
</ListView>
<ListView x:Name="OptionsListView"
Grid.Row="2"
Width="{TemplateBinding OpenPaneLength}"
VerticalAlignment="Bottom"
AutomationProperties.Name="Option items"
IsItemClickEnabled="True"
ItemContainerStyle="{StaticResource HambugerMenuItemStyle}"
ItemTemplate="{TemplateBinding OptionsItemTemplate}"
ItemTemplateSelector="{TemplateBinding OptionsItemTemplateSelector}"
ItemsSource="{TemplateBinding OptionsItemsSource}"
ScrollViewer.VerticalScrollBarVisibility="Disabled"
SelectedIndex="{Binding SelectedOptionsIndex, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
SelectedItem="{Binding SelectedOptionsItem, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
SelectionMode="Single"
TabIndex="2"
Margin="0,20,0,8">
</ListView>
</Grid>
</SplitView.Pane>
<ContentPresenter x:Name="ContentPart"
AutomationProperties.Name="Content"
Content="{TemplateBinding Content}" />
</SplitView>
<Button x:Name="HamburgerButton"
Width="{TemplateBinding HamburgerWidth}"
Height="{TemplateBinding HamburgerHeight}"
Visibility="{TemplateBinding HamburgerVisibility}"
Margin="0,0,0,8"
Padding="0"
VerticalAlignment="Top"
AutomationProperties.Name="Main button"
Background="Transparent"
BorderThickness="0"
TabIndex="0">
<ContentControl Margin="{TemplateBinding HamburgerMargin}"
ContentTemplate="{TemplateBinding HamburgerMenuTemplate}"
Foreground="{TemplateBinding PaneForeground}"
IsTabStop="False" />
</Button>
</Grid>
</ControlTemplate>
</Setter.Value>
<Setter Property="Template" Value="{StaticResource HamburgerMenuTemplate}">
</Setter>
</Style>
</ResourceDictionary>

Просмотреть файл

@ -0,0 +1,44 @@
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
using System;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
namespace Microsoft.Toolkit.Uwp.UI.Controls
{
/// <summary>
/// <see cref="StyleSelector"/> to be used with <see cref="NavigationView"/>
/// HamburgerMenuNavViewItemStyleSelector is used by the <see cref="HamburgerMenu"/>
/// </summary>
[Obsolete("The HamburgerMenuNavViewItemStyleSelector will be removed alongside the HamburgerMenu in a future major release. Please use the NavigationView control available in the Fall Creators Update")]
public class HamburgerMenuNavViewItemStyleSelector : StyleSelector
{
/// <summary>
/// Gets or sets the <see cref="Style"/> to be set if the container is a <see cref="NavigationViewItem"/>
/// </summary>
public Style MenuItemStyle { get; set; }
/// <inheritdoc/>
protected override Style SelectStyleCore(object item, DependencyObject container)
{
if (container is NavigationViewItem)
{
return MenuItemStyle;
}
else
{
return null;
}
}
}
}

Просмотреть файл

@ -0,0 +1,86 @@
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
using System.Collections.Generic;
using System.Linq;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
namespace Microsoft.Toolkit.Uwp.UI.Controls
{
internal class HamburgerMenuNavViewItemTemplateSelector : DataTemplateSelector
{
#pragma warning disable CS0618 // Type or member is obsolete
private HamburgerMenu _hamburgerMenu;
#pragma warning restore CS0618 // Type or member is obsolete
#pragma warning disable CS0618 // Type or member is obsolete
internal HamburgerMenuNavViewItemTemplateSelector(HamburgerMenu hamburgerMenu)
#pragma warning restore CS0618 // Type or member is obsolete
{
_hamburgerMenu = hamburgerMenu;
}
private DataTemplate SelectItemTemplate(object item)
{
if (_hamburgerMenu == null)
{
return TemplateFromItemTemplateSelector(item);
}
if (_hamburgerMenu.ItemsSource is IEnumerable<object> items && items.Contains(item))
{
return TemplateFromItemTemplateSelector(item);
}
if (_hamburgerMenu.OptionsItemTemplate != null)
{
if (_hamburgerMenu.OptionsItemsSource is IEnumerable<object> options && options.Contains(item))
{
return TemplateFromOptionsItemTemplateSelector(item);
}
}
return TemplateFromItemTemplateSelector(item);
}
private DataTemplate TemplateFromItemTemplateSelector(object item)
{
if (_hamburgerMenu.ItemTemplateSelector != null)
{
return _hamburgerMenu.ItemTemplateSelector.SelectTemplate(item);
}
return _hamburgerMenu.ItemTemplate;
}
private DataTemplate TemplateFromOptionsItemTemplateSelector(object item)
{
if (_hamburgerMenu.OptionsItemTemplateSelector != null)
{
return _hamburgerMenu.OptionsItemTemplateSelector.SelectTemplate(item);
}
return _hamburgerMenu.OptionsItemTemplate;
}
protected override DataTemplate SelectTemplateCore(object item)
{
return SelectItemTemplate(item);
}
protected override DataTemplate SelectTemplateCore(object item, DependencyObject container)
{
return SelectItemTemplate(item);
}
}
}

Просмотреть файл

@ -0,0 +1,171 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converters="using:Microsoft.Toolkit.Uwp.UI.Converters"
xmlns:local="using:Microsoft.Toolkit.Uwp.UI.Controls">
<Style TargetType="NavigationViewItem" x:Key="NavigationViewItemToolkitStyle">
<Setter Property="Foreground" Value="{ThemeResource NavigationViewItemForeground}" />
<Setter Property="Background" Value="{ThemeResource NavigationViewItemBackground}" />
<Setter Property="BorderBrush" Value="{ThemeResource NavigationViewItemBorderBrush}" />
<Setter Property="BorderThickness" Value="{StaticResource NavigationViewItemBorderThickness}" />
<Setter Property="UseSystemFocusVisuals" Value="True" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="NavigationViewItem">
<Grid
x:Name="LayoutRoot"
Height="40"
Background="{TemplateBinding Background}"
Control.IsTemplateFocusTarget="True">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="PointerStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="PointerOver">
<VisualState.Setters>
<Setter Target="LayoutRoot.(RevealBrush.State)" Value="PointerOver" />
<Setter Target="LayoutRoot.Background" Value="{ThemeResource NavigationViewItemBackgroundPointerOver}" />
<Setter Target="RevealBorder.BorderBrush" Value="{ThemeResource NavigationViewItemBorderBrushPointerOver}" />
<Setter Target="ContentPresenter.Foreground" Value="{ThemeResource NavigationViewItemForegroundPointerOver}" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Pressed">
<VisualState.Setters>
<Setter Target="LayoutRoot.(RevealBrush.State)" Value="Pressed" />
<Setter Target="LayoutRoot.Background" Value="{ThemeResource NavigationViewItemBackgroundPressed}" />
<Setter Target="RevealBorder.BorderBrush" Value="{ThemeResource NavigationViewItemBorderBrushPressed}" />
<Setter Target="ContentPresenter.Foreground" Value="{ThemeResource NavigationViewItemForegroundPressed}" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Selected">
<VisualState.Setters>
<Setter Target="LayoutRoot.Background" Value="{ThemeResource NavigationViewItemBackgroundSelected}" />
<Setter Target="RevealBorder.BorderBrush" Value="{ThemeResource NavigationViewItemBorderBrushSelected}" />
<Setter Target="ContentPresenter.Foreground" Value="{ThemeResource NavigationViewItemForegroundSelected}" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="PointerOverSelected">
<VisualState.Setters>
<Setter Target="LayoutRoot.(RevealBrush.State)" Value="PointerOver" />
<Setter Target="LayoutRoot.Background" Value="{ThemeResource NavigationViewItemBackgroundSelectedPointerOver}" />
<Setter Target="RevealBorder.BorderBrush" Value="{ThemeResource NavigationViewItemBorderBrushSelectedPointerOver}" />
<Setter Target="ContentPresenter.Foreground" Value="{ThemeResource NavigationViewItemForegroundSelectedPointerOver}" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="PressedSelected">
<VisualState.Setters>
<Setter Target="LayoutRoot.(RevealBrush.State)" Value="Pressed" />
<Setter Target="LayoutRoot.Background" Value="{ThemeResource NavigationViewItemBackgroundSelectedPressed}" />
<Setter Target="RevealBorder.BorderBrush" Value="{ThemeResource NavigationViewItemBorderBrushSelectedPressed}" />
<Setter Target="ContentPresenter.Foreground" Value="{ThemeResource NavigationViewItemForegroundSelectedPressed}" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
<VisualStateGroup x:Name="DisabledStates">
<VisualState x:Name="Enabled" />
<VisualState x:Name="Disabled">
<VisualState.Setters>
<Setter Target="LayoutRoot.Opacity" Value="{ThemeResource ListViewItemDisabledThemeOpacity}" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
<VisualStateGroup x:Name="PaneStates">
<VisualState x:Name="NotClosedCompact" />
<VisualState x:Name="ClosedCompact">
<VisualState.Setters>
<Setter Target="RevealBorder.HorizontalAlignment" Value="Left" />
<Setter Target="RevealBorder.Width" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=CompactPaneLength}" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
<VisualStateGroup x:Name="IconStates">
<VisualState x:Name="IconVisible" />
<VisualState x:Name="IconCollapsed">
<VisualState.Setters>
<Setter Target="IconBox.Visibility" Value="Collapsed" />
<Setter Target="IconColumn.Width" Value="16" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<!-- Wrap SelectionIndicator in a grid so that its offset is 0,0 - this enables the offset animation. -->
<Grid
HorizontalAlignment="Left"
VerticalAlignment="Center">
<Rectangle
x:Name="SelectionIndicator"
Width="6"
Height="24"
Fill="{ThemeResource NavigationViewSelectionIndicatorForeground}"
Opacity="0.0"/>
</Grid>
<Border
x:Name="RevealBorder"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}" />
<Grid Height="40" HorizontalAlignment="Left">
<Grid.ColumnDefinitions>
<ColumnDefinition x:Name="IconColumn" Width="48" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Viewbox x:Name="IconBox"
Child="{TemplateBinding Icon}"
Margin="16,12"/>
<ContentPresenter x:Name="ContentPresenter"
Grid.ColumnSpan="2"
ContentTransitions="{TemplateBinding ContentTransitions}"
ContentTemplate="{TemplateBinding ContentTemplate}"
Content="{TemplateBinding Content}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Margin="{TemplateBinding Padding}"/>
</Grid>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<ControlTemplate x:Key="HamburgerMenuNavViewTemplate" TargetType="local:HamburgerMenu">
<Grid>
<Grid.Resources>
<converters:VisibilityToBoolConverter x:Key="VisibilityToBoolConverter"></converters:VisibilityToBoolConverter>
<local:HamburgerMenuNavViewItemStyleSelector x:Key="HamburgerMenuNavViewItemStyleSelector"
MenuItemStyle="{StaticResource NavigationViewItemToolkitStyle}"></local:HamburgerMenuNavViewItemStyleSelector>
</Grid.Resources>
<NavigationView x:Name="NavView"
IsPaneOpen="{Binding IsPaneOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
MenuItemContainerStyleSelector="{StaticResource HamburgerMenuNavViewItemStyleSelector}"
AlwaysShowHeader="False"
CompactPaneLength="{TemplateBinding CompactPaneLength}"
OpenPaneLength="{TemplateBinding OpenPaneLength}"
IsSettingsVisible="False"
IsPaneToggleButtonVisible="{Binding HamburgerVisibility, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource VisibilityToBoolConverter}}"
Header="{x:Null}">
<ContentPresenter x:Name="ContentPart"
AutomationProperties.Name="Content"
Content="{TemplateBinding Content}" />
</NavigationView>
</Grid>
</ControlTemplate>
</ResourceDictionary>

Просмотреть файл

@ -0,0 +1,164 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Microsoft.Toolkit.Uwp.UI.Controls">
<Style x:Key="HambugerMenuItemStyle" TargetType="ListViewItem">
<Setter Property="Foreground" Value="{ThemeResource SystemControlForegroundBaseHighBrush}" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="MinHeight" Value="0"/>
<Setter Property="Padding" Value="0"/>
<Setter Property="UseSystemFocusVisuals" Value="True" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="VerticalContentAlignment" Value="Stretch" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListViewItem">
<Grid x:Name="LayoutRoot"
Background="{TemplateBinding Background}"
Control.IsTemplateFocusTarget="True"
Height="40">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="PointerStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="PointerOver">
<VisualState.Setters>
<Setter Target="LayoutRoot.Background" Value="{ThemeResource SystemControlHighlightListLowBrush}" />
<Setter Target="ContentPresenter.Foreground" Value="{ThemeResource SystemControlHighlightAltBaseHighBrush}" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Pressed">
<VisualState.Setters>
<Setter Target="LayoutRoot.Background" Value="{ThemeResource SystemControlHighlightListMediumBrush}" />
<Setter Target="ContentPresenter.Foreground" Value="{ThemeResource SystemControlHighlightAltBaseHighBrush}" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Selected">
<VisualState.Setters>
<Setter Target="SelectionIndicator.Opacity" Value="1.0" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="PointerOverSelected">
<VisualState.Setters>
<Setter Target="LayoutRoot.Background" Value="{ThemeResource SystemControlHighlightListLowBrush}" />
<Setter Target="ContentPresenter.Foreground" Value="{ThemeResource SystemControlHighlightAltBaseHighBrush}" />
<Setter Target="SelectionIndicator.Opacity" Value="1.0" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="PressedSelected">
<VisualState.Setters>
<Setter Target="LayoutRoot.Background" Value="{ThemeResource SystemControlHighlightListMediumBrush}" />
<Setter Target="ContentPresenter.Foreground" Value="{ThemeResource SystemControlHighlightAltBaseHighBrush}" />
<Setter Target="SelectionIndicator.Opacity" Value="1.0" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
<VisualStateGroup x:Name="DisabledStates">
<VisualState x:Name="Enabled" />
<VisualState x:Name="Disabled">
<VisualState.Setters>
<Setter Target="LayoutRoot.Opacity" Value="{ThemeResource ListViewItemDisabledThemeOpacity}" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<!-- Wrap SelectionIndicator in a grid so that its offset is 0,0 - this enables the offset animation. -->
<Grid HorizontalAlignment="Left" VerticalAlignment="Center">
<Rectangle x:Name="SelectionIndicator"
Fill="{ThemeResource SystemControlForegroundAccentBrush}"
Height="24"
Opacity="0.0"
Width="6"/>
</Grid>
<ContentPresenter x:Name="ContentPresenter"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
ContentTransitions="{TemplateBinding ContentTransitions}"
Grid.Column="1"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
Margin="{TemplateBinding Padding}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<ControlTemplate x:Key="HamburgerMenuTemplate" TargetType="local:HamburgerMenu">
<Grid>
<SplitView x:Name="MainSplitView"
CompactPaneLength="{TemplateBinding CompactPaneLength}"
DisplayMode="{TemplateBinding DisplayMode}"
IsPaneOpen="{Binding IsPaneOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
IsTabStop="False"
OpenPaneLength="{TemplateBinding OpenPaneLength}"
PaneBackground="{TemplateBinding PaneBackground}"
PanePlacement="{TemplateBinding PanePlacement}">
<SplitView.Pane>
<Grid x:Name="PaneGrid"
FlowDirection="LeftToRight">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid Grid.Row="0"
Height="{TemplateBinding HamburgerHeight}"
Margin="0,0,0,8" />
<ListView x:Name="ButtonsListView"
Grid.Row="1"
Width="{TemplateBinding OpenPaneLength}"
AutomationProperties.Name="Menu items"
IsItemClickEnabled="True"
ItemContainerStyle="{StaticResource HambugerMenuItemStyle}"
ItemTemplate="{TemplateBinding ItemTemplate}"
ItemTemplateSelector="{TemplateBinding ItemTemplateSelector}"
ItemsSource="{TemplateBinding ItemsSource}"
ScrollViewer.VerticalScrollBarVisibility="Auto"
SelectedIndex="{Binding SelectedIndex, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
SelectedItem="{Binding SelectedItem, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
SelectionMode="Single"
TabIndex="1">
</ListView>
<ListView x:Name="OptionsListView"
Grid.Row="2"
Width="{TemplateBinding OpenPaneLength}"
VerticalAlignment="Bottom"
AutomationProperties.Name="Option items"
IsItemClickEnabled="True"
ItemContainerStyle="{StaticResource HambugerMenuItemStyle}"
ItemTemplate="{TemplateBinding OptionsItemTemplate}"
ItemTemplateSelector="{TemplateBinding OptionsItemTemplateSelector}"
ItemsSource="{TemplateBinding OptionsItemsSource}"
ScrollViewer.VerticalScrollBarVisibility="Disabled"
SelectedIndex="{Binding SelectedOptionsIndex, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
SelectedItem="{Binding SelectedOptionsItem, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
SelectionMode="Single"
TabIndex="2"
Margin="0,20,0,8">
</ListView>
</Grid>
</SplitView.Pane>
<ContentPresenter x:Name="ContentPart"
AutomationProperties.Name="Content"
Content="{TemplateBinding Content}" />
</SplitView>
<Button x:Name="HamburgerButton"
Width="{TemplateBinding HamburgerWidth}"
Height="{TemplateBinding HamburgerHeight}"
Visibility="{TemplateBinding HamburgerVisibility}"
Margin="0,0,0,8"
Padding="0"
VerticalAlignment="Top"
AutomationProperties.Name="Main button"
Background="Transparent"
BorderThickness="0"
TabIndex="0">
<ContentControl Margin="{TemplateBinding HamburgerMargin}"
ContentTemplate="{TemplateBinding HamburgerMenuTemplate}"
Foreground="{TemplateBinding PaneForeground}"
IsTabStop="False" />
</Button>
</Grid>
</ControlTemplate>
</ResourceDictionary>

Просмотреть файл

@ -0,0 +1,33 @@
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
using System;
namespace Microsoft.Toolkit.Uwp.UI.Controls
{
/// <summary>
/// EventArgs used for the <see cref="HamburgerMenu"/> ItemInvoked event
/// </summary>
[Obsolete("The HamburgetMenuItemInvokedEventArgs will be removed alongside the HamburgerMenu in a future major release. Please use the NavigationView control available in the Fall Creators Update")]
public class HamburgetMenuItemInvokedEventArgs : EventArgs
{
/// <summary>
/// Gets the invoked item
/// </summary>
public object InvokedItem { get; internal set; }
/// <summary>
/// Gets a value indicating whether the invoked item is an options item
/// </summary>
public bool IsItemOptions { get; internal set; }
}
}

Просмотреть файл

@ -10,6 +10,7 @@
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
using System;
using Windows.UI.Xaml;
namespace Microsoft.Toolkit.Uwp.UI.Controls
@ -17,6 +18,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
/// <summary>
/// The HamburgerMenuGlyphItem provides a glyph based implementation for HamburgerMenu entries.
/// </summary>
[Obsolete("The HamburgerMenuGlyphItem will be removed alongside the HamburgerMenu in a future major release. Please use the NavigationView control available in the Fall Creators Update")]
public class HamburgerMenuGlyphItem : HamburgerMenuItem
{
/// <summary>

Просмотреть файл

@ -10,15 +10,16 @@
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
using System;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Media.Imaging;
namespace Microsoft.Toolkit.Uwp.UI.Controls
{
/// <summary>
/// The HamburgerMenuImageItem provides an image based implementation for HamburgerMenu entries.
/// </summary>
[Obsolete("The HamburgerMenuImageItem will be removed alongside the HamburgerMenu in a future major release. Please use the NavigationView control available in the Fall Creators Update")]
public class HamburgerMenuImageItem : HamburgerMenuItem
{
/// <summary>

Просмотреть файл

@ -12,13 +12,13 @@
using System;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
namespace Microsoft.Toolkit.Uwp.UI.Controls
{
/// <summary>
/// The HamburgerMenuItem provides an abstract implementation for HamburgerMenu entries.
/// </summary>
[Obsolete("The HamburgerMenuItem will be removed alongside the HamburgerMenu in a future major release. Please use the NavigationView control available in the Fall Creators Update")]
public abstract class HamburgerMenuItem : DependencyObject
{
/// <summary>

Просмотреть файл

@ -10,6 +10,7 @@
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
using System;
using System.Collections.Generic;
namespace Microsoft.Toolkit.Uwp.UI.Controls
@ -17,6 +18,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
/// <summary>
/// The HamburgerMenuItemCollection provides typed collection of HamburgerMenuItem.
/// </summary>
[Obsolete("The HamburgerMenuItemCollection will be removed alongside the HamburgerMenu in a future major release. Please use the NavigationView control available in the Fall Creators Update")]
public class HamburgerMenuItemCollection : List<HamburgerMenuItem>
{
}

Просмотреть файл

@ -8,7 +8,7 @@
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="controls:ImageEx">
<Grid Background="{TemplateBinding Background}">
<Grid Background="{TemplateBinding Background}" CornerRadius="{TemplateBinding CornerRadius}">
<Image Name="PlaceholderImage"
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
VerticalAlignment="{TemplateBinding VerticalAlignment}"

Просмотреть файл

@ -28,6 +28,11 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
/// </summary>
public static readonly DependencyProperty StretchProperty = DependencyProperty.Register(nameof(Stretch), typeof(Stretch), typeof(ImageExBase), new PropertyMetadata(Stretch.Uniform));
/// <summary>
/// Identifies the <see cref="CornerRadius"/> dependency property.
/// </summary>
public static readonly DependencyProperty CornerRadiusProperty = DependencyProperty.Register(nameof(CornerRadius), typeof(CornerRadius), typeof(ImageExBase), new PropertyMetadata(new CornerRadius(0)));
/// <summary>
/// Identifies the <see cref="DecodePixelHeight"/> dependency property.
/// </summary>
@ -86,6 +91,16 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
/// </summary>
public bool IsInitialized { get; private set; }
/// <summary>
/// Gets or sets the CornerRadius for underlying image. <para/>
/// Used to created rounded/circular images.
/// </summary>
public CornerRadius CornerRadius
{
get { return (CornerRadius)GetValue(CornerRadiusProperty); }
set { SetValue(CornerRadiusProperty, value); }
}
/// <summary>
/// Gets or sets DecodePixelHeight for underlying bitmap
/// </summary>

Просмотреть файл

@ -10,6 +10,7 @@
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
using System;
using Windows.UI.Composition;
using Windows.UI.Xaml;
@ -25,13 +26,14 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
/// <summary>
/// Identifies the <see cref="CornerRadius"/> dependency property.
/// </summary>
public static readonly DependencyProperty CornerRadiusProperty =
public static new readonly DependencyProperty CornerRadiusProperty =
DependencyProperty.Register(nameof(CornerRadius), typeof(double), typeof(RoundImageEx), new PropertyMetadata(0));
/// <summary>
/// Gets or sets the corner radius of the image
/// </summary>
public double CornerRadius
[Obsolete("Use ImageEx directly instead for 16299 and above.", false)]
public new double CornerRadius
{
get { return (double)GetValue(CornerRadiusProperty); }
set { SetValue(CornerRadiusProperty, value); }

Просмотреть файл

@ -10,6 +10,7 @@
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
using System;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Shapes;
@ -22,6 +23,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
/// Once downloaded, the source image is stored in the App local cache to preserve resources and load time next time the image needs to be displayed.
/// </summary>
[TemplatePart(Name = PartImageRectangle, Type = typeof(Rectangle))]
[Obsolete("Use CornerRadius on ImageEx instead for 16299 and above.", false)]
public partial class RoundImageEx : ImageExBase
{
/// <summary>

Просмотреть файл

@ -11,7 +11,7 @@
<ItemGroup>
<PackageReference Include="Robmikh.CompositionSurfaceFactory" Version="0.7.2" />
<PackageReference Include="Robmikh.CompositionSurfaceFactory" Version="0.7.3" />
<ProjectReference Include="..\Microsoft.Toolkit.Uwp.UI.Animations\Microsoft.Toolkit.Uwp.UI.Animations.csproj" />
</ItemGroup>
@ -22,4 +22,13 @@
</ItemGroup>
<Import Project="$(MSBuildSDKExtrasTargets)" Condition="Exists('$(MSBuildSDKExtrasTargets)')" />
<!-- https://weblogs.asp.net/rweigelt/disable-warnings-in-generated-c-files-of-uwp-app -->
<Target Name="PragmaWarningDisablePrefixer" AfterTargets="MarkupCompilePass2">
<ItemGroup>
<GeneratedCSFiles Include="**\*.g.cs;**\*.g.i.cs" />
</ItemGroup>
<Message Text="CSFiles: @(GeneratedCSFiles->'&quot;%(Identity)&quot;')" />
<Exec Command="for %%f in (@(GeneratedCSFiles->'&quot;%(Identity)&quot;')) do echo #pragma warning disable &gt; %%f.temp &amp;&amp; type %%f &gt;&gt; %%f.temp &amp;&amp; move /y %%f.temp %%f &gt; NUL" />
</Target>
</Project>

Просмотреть файл

@ -15,6 +15,7 @@ using System.Windows.Input;
using Microsoft.Toolkit.Uwp.UI.Animations;
using Windows.Devices.Input;
using Windows.Foundation;
using Windows.Foundation.Metadata;
using Windows.UI;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
@ -31,6 +32,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
[TemplatePart(Name = PartCommandContainer, Type = typeof(Grid))]
[TemplatePart(Name = PartLeftCommandPanel, Type = typeof(StackPanel))]
[TemplatePart(Name = PartRightCommandPanel, Type = typeof(StackPanel))]
[Obsolete("The SlidableListItem will be removed in a future major release. Please use the SwipeControl available in the Fall Creators Update")]
public class SlidableListItem : ContentControl
{
/// <summary>
@ -49,13 +51,13 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
/// Identifies the <see cref="IsRightCommandEnabled"/> property
/// </summary>
public static readonly DependencyProperty IsRightCommandEnabledProperty =
DependencyProperty.Register(nameof(IsRightCommandEnabled), typeof(bool), typeof(SlidableListItem), new PropertyMetadata(true));
DependencyProperty.Register(nameof(IsRightCommandEnabled), typeof(bool), typeof(SlidableListItem), new PropertyMetadata(true, OnSwipeControlValueChanged));
/// <summary>
/// Identifies the <see cref="IsLeftCommandEnabled"/> property
/// </summary>
public static readonly DependencyProperty IsLeftCommandEnabledProperty =
DependencyProperty.Register(nameof(IsLeftCommandEnabled), typeof(bool), typeof(SlidableListItem), new PropertyMetadata(true));
DependencyProperty.Register(nameof(IsLeftCommandEnabled), typeof(bool), typeof(SlidableListItem), new PropertyMetadata(true, OnSwipeControlValueChanged));
/// <summary>
/// Identifies the <see cref="ActivationWidth"/> property
@ -64,52 +66,52 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
DependencyProperty.Register(nameof(ActivationWidth), typeof(double), typeof(SlidableListItem), new PropertyMetadata(80));
/// <summary>
/// Indeifies the <see cref="LeftIcon"/> property
/// Identifies the <see cref="LeftIcon"/> property
/// </summary>
public static readonly DependencyProperty LeftIconProperty =
DependencyProperty.Register(nameof(LeftIcon), typeof(Symbol), typeof(SlidableListItem), new PropertyMetadata(Symbol.Favorite));
DependencyProperty.Register(nameof(LeftIcon), typeof(Symbol), typeof(SlidableListItem), new PropertyMetadata(Symbol.Favorite, OnSwipeControlValueChanged));
/// <summary>
/// Identifies the <see cref="RightIcon"/> property
/// </summary>
public static readonly DependencyProperty RightIconProperty =
DependencyProperty.Register(nameof(RightIcon), typeof(Symbol), typeof(SlidableListItem), new PropertyMetadata(Symbol.Delete));
DependencyProperty.Register(nameof(RightIcon), typeof(Symbol), typeof(SlidableListItem), new PropertyMetadata(Symbol.Delete, OnSwipeControlValueChanged));
/// <summary>
/// Identifies the <see cref="LeftLabel"/> property
/// </summary>
public static readonly DependencyProperty LeftLabelProperty =
DependencyProperty.Register(nameof(LeftLabel), typeof(string), typeof(SlidableListItem), new PropertyMetadata(string.Empty));
DependencyProperty.Register(nameof(LeftLabel), typeof(string), typeof(SlidableListItem), new PropertyMetadata(string.Empty, OnSwipeControlValueChanged));
/// <summary>
/// Identifies the <see cref="RightLabel"/> property
/// </summary>
public static readonly DependencyProperty RightLabelProperty =
DependencyProperty.Register(nameof(RightLabel), typeof(string), typeof(SlidableListItem), new PropertyMetadata(string.Empty));
DependencyProperty.Register(nameof(RightLabel), typeof(string), typeof(SlidableListItem), new PropertyMetadata(string.Empty, OnSwipeControlValueChanged));
/// <summary>
/// Identifies the <see cref="LeftForeground"/> property
/// </summary>
public static readonly DependencyProperty LeftForegroundProperty =
DependencyProperty.Register(nameof(LeftForeground), typeof(Brush), typeof(SlidableListItem), new PropertyMetadata(new SolidColorBrush(Colors.White)));
DependencyProperty.Register(nameof(LeftForeground), typeof(Brush), typeof(SlidableListItem), new PropertyMetadata(new SolidColorBrush(Colors.White), OnSwipeControlValueChanged));
/// <summary>
/// Identifies the <see cref="RightForeground"/> property
/// </summary>
public static readonly DependencyProperty RightForegroundProperty =
DependencyProperty.Register(nameof(RightForeground), typeof(Brush), typeof(SlidableListItem), new PropertyMetadata(new SolidColorBrush(Colors.White)));
DependencyProperty.Register(nameof(RightForeground), typeof(Brush), typeof(SlidableListItem), new PropertyMetadata(new SolidColorBrush(Colors.White), OnSwipeControlValueChanged));
/// <summary>
/// Identifies the <see cref="LeftBackground"/> property
/// </summary>
public static readonly DependencyProperty LeftBackgroundProperty =
DependencyProperty.Register(nameof(LeftBackground), typeof(Brush), typeof(SlidableListItem), new PropertyMetadata(new SolidColorBrush(Colors.LightGray)));
DependencyProperty.Register(nameof(LeftBackground), typeof(Brush), typeof(SlidableListItem), new PropertyMetadata(new SolidColorBrush(Colors.LightGray), OnSwipeControlValueChanged));
/// <summary>
/// Identifies the <see cref="RightBackground"/> property
/// </summary>
public static readonly DependencyProperty RightBackgroundProperty =
DependencyProperty.Register(nameof(RightBackground), typeof(Brush), typeof(SlidableListItem), new PropertyMetadata(new SolidColorBrush(Colors.DarkGray)));
DependencyProperty.Register(nameof(RightBackground), typeof(Brush), typeof(SlidableListItem), new PropertyMetadata(new SolidColorBrush(Colors.DarkGray), OnSwipeControlValueChanged));
/// <summary>
/// Identifies the <see cref="MouseSlidingEnabled"/> property
@ -121,25 +123,25 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
/// Identifies the <see cref="LeftCommand"/> property
/// </summary>
public static readonly DependencyProperty LeftCommandProperty =
DependencyProperty.Register(nameof(LeftCommand), typeof(ICommand), typeof(SlidableListItem), new PropertyMetadata(null));
DependencyProperty.Register(nameof(LeftCommand), typeof(ICommand), typeof(SlidableListItem), new PropertyMetadata(null, OnSwipeControlValueChanged));
/// <summary>
/// Identifies the <see cref="RightCommand"/> property
/// </summary>
public static readonly DependencyProperty RightCommandProperty =
DependencyProperty.Register(nameof(RightCommand), typeof(ICommand), typeof(SlidableListItem), new PropertyMetadata(null));
DependencyProperty.Register(nameof(RightCommand), typeof(ICommand), typeof(SlidableListItem), new PropertyMetadata(null, OnSwipeControlValueChanged));
/// <summary>
/// Identifies the <see cref="LeftCommandParameter"/> property
/// </summary>
public static readonly DependencyProperty LeftCommandParameterProperty =
DependencyProperty.Register(nameof(LeftCommandParameter), typeof(object), typeof(SlidableListItem), new PropertyMetadata(null));
DependencyProperty.Register(nameof(LeftCommandParameter), typeof(object), typeof(SlidableListItem), new PropertyMetadata(null, OnSwipeControlValueChanged));
/// <summary>
/// Identifies the <see cref="RightCommandParameter"/> property
/// </summary>
public static readonly DependencyProperty RightCommandParameterProperty =
DependencyProperty.Register(nameof(RightCommandParameter), typeof(object), typeof(SlidableListItem), new PropertyMetadata(null));
DependencyProperty.Register(nameof(RightCommandParameter), typeof(object), typeof(SlidableListItem), new PropertyMetadata(null, OnSwipeControlValueChanged));
/// <summary>
/// Identifies the <see cref="SwipeStatus"/> property
@ -148,11 +150,17 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
DependencyProperty.Register(nameof(SwipeStatus), typeof(object), typeof(SlidableListItem), new PropertyMetadata(SwipeStatus.Idle));
/// <summary>
/// Identifues the <see cref="IsPointerReleasedOnSwipingHandled"/> property
/// Identifies the <see cref="IsPointerReleasedOnSwipingHandled"/> property
/// </summary>
public static readonly DependencyProperty IsPointerReleasedOnSwipingHandledProperty =
DependencyProperty.Register("IsPointerReleasedOnSwipingHandled", typeof(bool), typeof(SlidableListItem), new PropertyMetadata(false));
/// <summary>
/// Identifies the <see cref="UseSwipeControlWhenPossible"/> dependency property
/// </summary>
public static readonly DependencyProperty UseSwipeControlWhenPossibleProperty =
DependencyProperty.Register("UseSwipeControlWhenPossible", typeof(bool), typeof(SlidableListItem), new PropertyMetadata(false, OnUseSwipeControlWhenPossibleChanged));
/// <summary>
/// Occurs when SwipeStatus has changed
/// </summary>
@ -165,6 +173,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
private const int FinishAnimationDuration = 150;
private const int SnappedCommandMargin = 20;
private const int AnimationSetDuration = 200;
private Grid _contentGrid;
private CompositeTransform _transform;
private Grid _commandContainer;
@ -179,6 +188,20 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
private AnimationSet _leftCommandAnimationSet;
private AnimationSet _rightCommandAnimationSet;
private ControlTemplate _previousTemplateUsed;
private object _swipeControl;
private object _leftSwipeItems;
private object _leftSwipeItem;
private object _rightSwipeItems;
private object _rightSwipeItem;
private bool UsingSwipeControl => UseSwipeControlWhenPossible && IsSwipeControlSupported;
/// <summary>
/// Gets a value indicating whether <see cref="SwipeControl"/> is supported
/// </summary>
public static bool IsSwipeControlSupported { get; } = ApiInformation.IsTypePresent("Windows.UI.Xaml.Controls.SwipeControl");
/// <summary>
/// Initializes a new instance of the <see cref="SlidableListItem"/> class.
/// Creates a new instance of <see cref="SlidableListItem"/>
@ -226,12 +249,159 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
_contentGrid.ManipulationCompleted += ContentGrid_ManipulationCompleted;
}
if (UsingSwipeControl)
{
OnApplyTemplateSwipeControl();
}
Loaded += SlidableListItem_Loaded;
Unloaded += SlidableListItem_Unloaded;
base.OnApplyTemplate();
}
private static void OnUseSwipeControlWhenPossibleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var slider = d as SlidableListItem;
if (slider == null)
{
return;
}
if (slider.UseSwipeControlWhenPossible && SlidableListItem.IsSwipeControlSupported)
{
ResourceDictionary dict = new ResourceDictionary();
dict.Source = new System.Uri("ms-appx:///Microsoft.Toolkit.Uwp.UI.Controls/SlidableListItem/SlidableListItemSwipeControlTemplate.xaml");
slider._previousTemplateUsed = slider.Template;
slider.Template = dict["SlidableListItemSwipeControlStyle"] as ControlTemplate;
}
else if (!slider.UseSwipeControlWhenPossible &&
e.OldValue is bool oldValue &&
oldValue)
{
if (slider._previousTemplateUsed != null)
{
slider.Template = slider._previousTemplateUsed;
}
else
{
ResourceDictionary dict = new ResourceDictionary();
dict.Source = new System.Uri("ms-appx:///Microsoft.Toolkit.Uwp.UI.Controls/SlidableListItem/SlidableListItem.xaml");
slider.Template = dict["SlidableListItemDefaultTemplate"] as ControlTemplate;
}
}
}
private static void OnSwipeControlValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is SlidableListItem control && control.UsingSwipeControl)
{
control.UpdateSwipeControlItems();
}
}
private void OnApplyTemplateSwipeControl()
{
if (GetTemplateChild("SwipeControl") is SwipeControl swipeControl)
{
_swipeControl = swipeControl;
UpdateSwipeControlItems();
}
}
private void UpdateSwipeControlItems()
{
var swipeControl = _swipeControl as SwipeControl;
if (swipeControl == null)
{
return;
}
if (IsLeftCommandEnabled)
{
var leftItem = _leftSwipeItem as SwipeItem;
var leftItems = _leftSwipeItems as SwipeItems;
if (leftItem == null)
{
leftItem = new SwipeItem();
leftItem.IconSource = new SymbolIconSource();
leftItem.Invoked += LeftControl_Invoked;
leftItems = new SwipeItems()
{
leftItem
};
leftItems.Mode = SwipeMode.Execute;
_leftSwipeItems = leftItems;
_leftSwipeItem = leftItem;
}
leftItem.BehaviorOnInvoked = SwipeBehaviorOnInvoked.Close;
leftItem.Background = LeftBackground;
leftItem.Text = LeftLabel;
leftItem.Foreground = LeftForeground;
leftItem.Command = LeftCommand;
leftItem.CommandParameter = LeftCommandParameter;
leftItem.IconSource.Foreground = LeftForeground;
((SymbolIconSource)leftItem.IconSource).Symbol = LeftIcon;
swipeControl.LeftItems = leftItems;
}
else
{
swipeControl.LeftItems = null;
}
if (IsRightCommandEnabled)
{
var rightItem = _rightSwipeItem as SwipeItem;
var rightItems = _rightSwipeItems as SwipeItems;
if (rightItem == null)
{
rightItem = new SwipeItem();
rightItem.IconSource = new SymbolIconSource();
rightItem.Invoked += RightControl_Invoked;
rightItems = new SwipeItems()
{
rightItem
};
rightItems.Mode = SwipeMode.Execute;
_rightSwipeItems = rightItems;
_rightSwipeItem = rightItem;
}
rightItem.BehaviorOnInvoked = SwipeBehaviorOnInvoked.Close;
rightItem.Background = RightBackground;
rightItem.Text = RightLabel;
rightItem.Foreground = RightForeground;
rightItem.Command = RightCommand;
rightItem.CommandParameter = RightCommandParameter;
rightItem.IconSource.Foreground = RightForeground;
((SymbolIconSource)rightItem.IconSource).Symbol = RightIcon;
swipeControl.RightItems = rightItems;
}
else
{
swipeControl.RightItems = null;
}
}
private void LeftControl_Invoked(SwipeItem sender, SwipeItemInvokedEventArgs args)
{
LeftCommandRequested?.Invoke(this, EventArgs.Empty);
}
private void RightControl_Invoked(SwipeItem sender, SwipeItemInvokedEventArgs args)
{
RightCommandRequested?.Invoke(this, EventArgs.Empty);
}
private void SlidableListItem_Loaded(object sender, RoutedEventArgs e)
{
if (_contentStoryboard != null)
@ -487,7 +657,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
}
else if (SwipeStatus != SwipeStatus.SwipingPassedRightThreshold)
{
// This will cover extrem cases when previous state wasn't
// This will cover extreme cases when previous state wasn't
// below threshold.
_leftCommandAnimationSet?.Stop();
_leftCommandPanel.RenderTransform = _leftCommandTransform;
@ -528,7 +698,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
}
else if (SwipeStatus != SwipeStatus.SwipingPassedLeftThreshold)
{
// This will cover extrem cases when previous state wasn't
// This will cover extreme cases when previous state wasn't
// below threshold.
_rightCommandAnimationSet?.Stop();
_rightCommandPanel.RenderTransform = _rightCommandTransform;
@ -777,5 +947,15 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
get { return (bool)GetValue(IsPointerReleasedOnSwipingHandledProperty); }
set { SetValue(IsPointerReleasedOnSwipingHandledProperty, value); }
}
/// <summary>
/// Gets or sets a value indicating whether the SlidableListItem should use the SwipeControl when possible (Fall Creators Update and above)
/// When set to true and the device supports SwipeControl, the SlidableListItem will use a template based on SwipeControl
/// </summary>
public bool UseSwipeControlWhenPossible
{
get { return (bool)GetValue(UseSwipeControlWhenPossibleProperty); }
set { SetValue(UseSwipeControlWhenPossibleProperty, value); }
}
}
}

Просмотреть файл

@ -2,6 +2,52 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls">
<ControlTemplate TargetType="controls:SlidableListItem" x:Key="SlidableListItemDefaultTemplate">
<Grid>
<Grid x:Name="CommandContainer"
Margin="1"
x:DeferLoadStrategy="Lazy">
<StackPanel x:Name="LeftCommandPanel"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Orientation="Horizontal">
<SymbolIcon Foreground="{TemplateBinding LeftForeground}"
Symbol="{TemplateBinding LeftIcon}" />
<TextBlock Margin="10,0,0,0"
FontSize="15"
Foreground="{TemplateBinding LeftForeground}"
Text="{TemplateBinding LeftLabel}" />
<StackPanel.RenderTransform>
<CompositeTransform />
</StackPanel.RenderTransform>
</StackPanel>
<StackPanel x:Name="RightCommandPanel"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Orientation="Horizontal">
<TextBlock Margin="0,0,10,0"
FontSize="15"
Foreground="{TemplateBinding RightForeground}"
Text="{TemplateBinding RightLabel}" />
<SymbolIcon Foreground="{TemplateBinding RightForeground}"
Symbol="{TemplateBinding RightIcon}" />
<StackPanel.RenderTransform>
<CompositeTransform />
</StackPanel.RenderTransform>
</StackPanel>
</Grid>
<Grid x:Name="ContentGrid"
Background="{TemplateBinding Background}"
ManipulationMode="TranslateX,System">
<ContentPresenter />
<Grid.RenderTransform>
<CompositeTransform x:Name="ContentTransform" />
</Grid.RenderTransform>
</Grid>
</Grid>
</ControlTemplate>
<Style TargetType="controls:SlidableListItem">
<Setter Property="LeftForeground" Value="White" />
<Setter Property="RightForeground" Value="White" />
@ -11,54 +57,6 @@
<Setter Property="IsOffsetLimited" Value="True" />
<Setter Property="ExtraSwipeThreshold" Value="40" />
<Setter Property="IsTabStop" Value="False" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="controls:SlidableListItem">
<Grid>
<Grid x:Name="CommandContainer"
Margin="1"
x:DeferLoadStrategy="Lazy">
<StackPanel x:Name="LeftCommandPanel"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Orientation="Horizontal">
<SymbolIcon Foreground="{TemplateBinding LeftForeground}"
Symbol="{TemplateBinding LeftIcon}" />
<TextBlock Margin="10,0,0,0"
FontSize="15"
Foreground="{TemplateBinding LeftForeground}"
Text="{TemplateBinding LeftLabel}" />
<StackPanel.RenderTransform>
<CompositeTransform />
</StackPanel.RenderTransform>
</StackPanel>
<StackPanel x:Name="RightCommandPanel"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Orientation="Horizontal">
<TextBlock Margin="0,0,10,0"
FontSize="15"
Foreground="{TemplateBinding RightForeground}"
Text="{TemplateBinding RightLabel}" />
<SymbolIcon Foreground="{TemplateBinding RightForeground}"
Symbol="{TemplateBinding RightIcon}" />
<StackPanel.RenderTransform>
<CompositeTransform />
</StackPanel.RenderTransform>
</StackPanel>
</Grid>
<Grid x:Name="ContentGrid"
Background="{TemplateBinding Background}"
ManipulationMode="TranslateX,System">
<ContentPresenter />
<Grid.RenderTransform>
<CompositeTransform x:Name="ContentTransform" />
</Grid.RenderTransform>
</Grid>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="Template" Value="{StaticResource SlidableListItemDefaultTemplate}"></Setter>
</Style>
</ResourceDictionary>

Просмотреть файл

@ -0,0 +1,14 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converters="using:Microsoft.Toolkit.Uwp.UI.Converters"
xmlns:local="using:Microsoft.Toolkit.Uwp.UI.Controls">
<ControlTemplate x:Key="SlidableListItemSwipeControlStyle" TargetType="local:SlidableListItem">
<SwipeControl x:Name="SwipeControl">
<Grid Background="{TemplateBinding Background}">
<ContentPresenter />
</Grid>
</SwipeControl>
</ControlTemplate>
</ResourceDictionary>

Просмотреть файл

@ -10,15 +10,18 @@
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
using System;
namespace Microsoft.Toolkit.Uwp.UI.Controls
{
/// <summary>
/// Types of swipe status.
/// </summary>
[Obsolete("The SwipeStatus will be removed alongside SlidableListItem in a future major release. Please use the SwipeControl available in the Fall Creators Update")]
public enum SwipeStatus
{
/// <summary>
/// Swiping is not occuring.
/// Swiping is not occurring.
/// </summary>
Idle,

Просмотреть файл

@ -10,11 +10,14 @@
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
using System;
namespace Microsoft.Toolkit.Uwp.UI.Controls
{
/// <summary>
/// Event args for a SwipeStatus changing event
/// </summary>
[Obsolete("The SwipeStatusChangedEventArgs will be removed alongside SlidableListItem in a future major release. Please use the SwipeControl available in the Fall Creators Update")]
public class SwipeStatusChangedEventArgs
{
/// <summary>

Просмотреть файл

@ -0,0 +1,50 @@
// ******************************************************************
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THE CODE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE CODE OR THE USE OR OTHER DEALINGS IN THE CODE.
// ******************************************************************
using System;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Data;
namespace Microsoft.Toolkit.Uwp.UI.Converters
{
/// <summary>
/// This class converts a Visibility enumeration to a boolean value.
/// </summary>
public class VisibilityToBoolConverter : IValueConverter
{
/// <summary>
/// Convert a <see cref="Visibility"/> value to boolean.
/// </summary>
/// <param name="value">The <see cref="Visibility"/> value to convert.</param>
/// <param name="targetType">The type of the target property, as a type reference.</param>
/// <param name="parameter">Optional parameter. Not used.</param>
/// <param name="language">The language of the conversion. Not used</param>
/// <returns>The value to be passed to the target dependency property.</returns>
public object Convert(object value, Type targetType, object parameter, string language)
{
return value is Visibility visibility && visibility == Visibility.Visible;
}
/// <summary>
/// Convert back a boolean value to <see cref="Visibility"/>.
/// </summary>
/// <param name="value">The <see cref="Visibility"/> value to convert back.</param>
/// <param name="targetType">The type of the target property, as a type reference.</param>
/// <param name="parameter">Optional parameter. Not used.</param>
/// <param name="language">The language of the conversion. Not used</param>
/// <returns>The value to be passed to the target dependency property.</returns>
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
return (value is bool bl && bl) ? Visibility.Visible : Visibility.Collapsed;
}
}
}

Просмотреть файл

@ -5,6 +5,9 @@
<Title>UWP Community Toolkit .NET Standard</Title>
<Description>This package includes .NET Standard code only helpers.</Description>
<PackageTags>UWP Toolkit Windows</PackageTags>
<!-- This is a temporary workaround for https://github.com/dotnet/sdk/issues/955 -->
<DebugType>Full</DebugType>
</PropertyGroup>
</Project>

Просмотреть файл

@ -11,7 +11,7 @@
<AssemblyName>UnitTests.Notifications.UWP</AssemblyName>
<DefaultLanguage>en-US</DefaultLanguage>
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
<TargetPlatformVersion>10.0.15063.0</TargetPlatformVersion>
<TargetPlatformVersion>10.0.16299.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.10586.0</TargetPlatformMinVersion>
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
<FileAlignment>512</FileAlignment>
@ -99,7 +99,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
<Version>5.3.4</Version>
<Version>5.4.1</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>

Просмотреть файл

@ -11,7 +11,7 @@
<AssemblyName>UnitTests.Notifications.WinRT</AssemblyName>
<DefaultLanguage>en-US</DefaultLanguage>
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
<TargetPlatformVersion>10.0.15063.0</TargetPlatformVersion>
<TargetPlatformVersion>10.0.16299.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.10586.0</TargetPlatformMinVersion>
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
<FileAlignment>512</FileAlignment>
@ -99,7 +99,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
<Version>5.3.4</Version>
<Version>5.4.1</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>

Просмотреть файл

@ -11,7 +11,7 @@
<AssemblyName>UnitTests</AssemblyName>
<DefaultLanguage>en-US</DefaultLanguage>
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
<TargetPlatformVersion>10.0.15063.0</TargetPlatformVersion>
<TargetPlatformVersion>10.0.16299.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.14393.0</TargetPlatformMinVersion>
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
<FileAlignment>512</FileAlignment>
@ -112,7 +112,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
<Version>5.3.4</Version>
<Version>5.4.1</Version>
</PackageReference>
<PackageReference Include="StyleCop.Analyzers">
<Version>1.0.2</Version>

Просмотреть файл

@ -46,6 +46,9 @@ PR has to be validated by at least two core members before being merged.
Once merged, you can get a pre-release package of the toolkit by adding this ([Nuget repo](https://dotnet.myget.org/F/uwpcommunitytoolkit/api/v3/index.json) | [Gallery](https://dotnet.myget.org/gallery/uwpcommunitytoolkit)) to your Visual Studio.
### What about the t-shirt?
Did your contribute but didin't get the t-shirt? Then make sure to fill out [this form](https://1drv.ms/xs/s!AjZLNGpIZBbgr7ZvtqjV-LcgdRcc7A).
## <a name="xaml"></a> Quality assurance for pull requests for XAML controls
We encourage developers to follow the following guidances when submitting pull requests for controls:
* Your control must be usable and efficient with keyboard only

Просмотреть файл

@ -8,6 +8,9 @@ keywords: windows 10, uwp, uwp community toolkit, uwp toolkit, parallaxservice
# ParallaxService
> [!NOTE]
The ParallaxService is deprecated and will be removed in a future major release. Please use the [ParallaxView](https://docs.microsoft.com/en-us/windows/uwp/style/parallax) available in the Fall Creators Update. Read the [Moving to ParallaxView](#parallaxview) section for more info.
The ParallaxService class allows to create a parallax effect for items contained within an element that scrolls like a ScrollViewer or ListView.
## Syntax
@ -40,6 +43,28 @@ MyUIElement.SetValue(ParallaxService.HorizontalMultiplierProperty, 0.5);
[ParallaxService Sample Page Source](https://github.com/Microsoft/UWPCommunityToolkit/tree/master/Microsoft.Toolkit.Uwp.SampleApp/SamplePages/ParallaxService). You can see this in action in [UWP Community Toolkit Sample App](https://www.microsoft.com/store/apps/9NBLGGH4TLCQ)
## <a name="parallaxview"></a> Moving to ParallaxView
The Windows 10 Fall Creators Update SDK now includes the [ParallaxView](https://docs.microsoft.com/en-us/windows/uwp/style/parallax) control among other new controls and APIs. The ParallaxService and ParallaxView share the same concepts and provide the same functionality. In fact, the ParallaxView adds even more functionality and can be used in even more scenarios.
However, the way the two are used is different. Unlike the ParallaxService, the ParallaxView is a control hosting the background element. This control ties the scroll position of a foreground element, such as a list, to a background element, such as an image. As you scroll through the foreground element, it animates the background element to create a parallax effect. To use the ParallaxView control, you provide a Source element, a background element, and set the VerticalShift (for vertical scrolling) and/or HorizontalShift (for horizontal scrolling) properties to a value greater than zero. To create a parallax effect, the ParallaxView must be behind the foreground element.
Here is an example of using the ParallaxView
```csharp
<Grid>
<ParallaxView Source="{x:Bind ForegroundElement}" VerticalShift="50">
<!-- Background element -->
<Image x:Name="BackgroundImage" Source="mybackgroundimage.png"
Stretch="UniformToFill"/>
</ParallaxView>
<!-- Foreground element -->
<ListView x:Name="ForegroundElement" ItemsSource="{x:Bind Items}">
</ListView>
</Grid>
```
## Requirements
| [Device family](http://go.microsoft.com/fwlink/p/?LinkID=526370) | Universal, 10.0.14393.0 or higher |

Просмотреть файл

@ -17,6 +17,7 @@ You can use these properties :
* HeaderTemplate
* IsExpanded (define if the content is visible or not)
* ExpandDirection
* DisplayMode
You can also use these events :
@ -52,6 +53,13 @@ The `ExpandDirection` property can take 4 values that will expand the content ba
* `Right` - from left to right
* `Left` - from right to left
### DisplayMode
The `DisplayMode` property can take 2 values that will modify the behavior of the Expander control:
* `Expand` - the content is either visible or collapsed (default)
* `Overlay` - when the content is collapsed, an overlay content is shown
## Example Image
![Expander animation](../resources/images/Controls-Expander.gif "Expander")

Просмотреть файл

@ -1,13 +1,16 @@
---
title: HamburgerMenu XAML Control
author: nmetulev
ms.date: 08/20/2017
ms.date: 11/20/2017
description: The Hamburger Menu Control provides an easy-to-use, side-bar menu which users can show or hide by using a Hamburger button
keywords: windows 10, uwp, uwp community toolkit, uwp toolkit, HamburgerMenu, xaml control, xaml
---
# HamburgerMenu XAML Control
> [!NOTE]
The HamburgerMenu is deprecated and will be removed in a future major release. Please use the [NavigationView](https://docs.microsoft.com/en-us/windows/uwp/controls-and-patterns/navigationview) available in the Fall Creators Update. Read the [Moving to NavigationView](#navview) section for more info.
The **Hamburger Menu Control** provides an easy-to-use, side-bar menu which users can show or hide by using a Hamburger button. By tapping the icon, it opens up a side menu with a selection of options or additional pages.
### How it works
@ -143,6 +146,56 @@ namespace HamburgerSample
```
## <a name="navview"></a> Moving to NavigationView
The Windows 10 Fall Creators Update SDK now includes the [NavigationView](https://docs.microsoft.com/en-us/windows/uwp/controls-and-patterns/navigationview) control among other new controls and APIs. This is great news for the UWP Community Toolkit as it means that one of its most popular controls, the HamburgerMenu, has a comparable counterpart in the Windows SDK and it is very easy to transition to the NavigationView if you are already using the HamburgerMenu.
The HamburgerMenu and NavigationView share the same concepts and provide the same functionality with one major exception being the NavigationView takes advantage of the new fluent design system. In fact, the NavigationView does everything the HamburgerMenu does and even more.
### What developers need to know to move to NavigationView?
* **Pane:** Both the NavigationView and HamburgerMenu are based on the SplitView, so the same properties exist in both controls. However, the NavigationView uses the new AcrylicBrush for the background which creates the semi-transparent material out of the box. Additionally, the navigation view automatically changes its display mode based on the amount of screen size available to it, so you are no longer required to write all that code.
* **NavigationViewItems and Item Templates:** The NavigationView uses a similar pattern to define the Menu Items, with some naming changes. Here is the mapping from some properties in the HamburgerMenu to the comparable properties in the NavigationView:
| HamburgerMenu | NavigationView |
| --- | --- |
| ItemsSource | MenuItemsSource |
| ItemTemplate | MenuItemTemplate |
| ItemClick | ItemInvoked |
The *OptionsItemsSource* and *OptionItemsTemplate* is not available in the NavigationView. Instead, the NavigationView has two additional new properties that provide a much more flexible way of handling settings and optional items:
* An optional property for app settings. Simply set the property *IsSettingsVisible* to true and the NavigationView will display the settings button at the bottom. You can even customize the settings item
```csharp
var settingsItem = HamburgerMenu.SettingsItem as NavigationViewItem;
settingsItem.Content = "About";
settingsItem.Icon = new FontIcon() { Glyph = "?" };
```
* Free-form content in the panes footer, by adding any content in the new *PaneFooter* property
In addition, the NavigationView introduces new classes for quickly adding navigation items and grouping items. You can use the new NavigationViewItem, NavigationViewItemSeparator and NavigationViewItemHeader to directly populate the MenuItems and get the look you want
* **Additional features in the NavigationView:** The navigation view also introduces several new features that are not available in the HamburgerMenu:
* There is a new optional header area that is vertically aligned with the navigation button and has a fixed height. Its purpose is to hold the page title of the selected nav category. The header is docked to the top of the page and acts as a scroll clipping point for the content area.
* AutoSuggestBox property allows you to add a search box that integrates directly with the NavigationView. Some developers accomplished the same with the HamburgerMenu by re-templating it and writing a lot of custom code. That is not needed with the NavigationView
### Making the transition even easier
Starting with v2.1 of the UWP Community Toolkit, the HamburgerMenu provides a new property called **UseNavigationViewWhenPossible**. Setting the value to true will force the HamburgerMenu to use a template based on the NavigationView when running on the Fall Creators Update and above, and the regular template otherwise.
Using this property will enable you to take advantage of the NavigationView on devices that supported the NavigationView, while providing an experience based on HamburgerMenu on devices that have not yet updated to the Fall Creators Update. Make sure to test the experience on multiple OS releases and plan to fully transition to the NavigationView as the HamburgerMenu will be removed from the UWP Community Toolkit in a future major release.
There are several HamburgerMenu properties that have no effect when the HamburgerMenu is using the NavigationView:
* DisplayMode
* PanePlacement
* PaneBackground
* PaneForeground
* HamburgerWidth
* HamburgerHeight
* HamburgerMargin
* HamburgerMenuTemplate
## Default Template
[HamburgerMenu XAML File](https://github.com/Microsoft/UWPCommunityToolkit/blob/master/Microsoft.Toolkit.Uwp.UI.Controls/HamburgerMenu/HamburgerMenu.xaml) is the XAML template used in the toolkit for the default styling.

Просмотреть файл

@ -43,6 +43,10 @@ You can also use a placeholder image that will be displayed will loading the mai
[ImageEx Control XAML File](https://github.com/Microsoft/UWPCommunityToolkit/blob/master/Microsoft.Toolkit.Uwp.UI.Controls/ImageEx/ImageEx.xaml) is the XAML template used in the toolkit for the default styling.
[RoundImageEx Control XAML File](https://github.com/Microsoft/UWPCommunityToolkit/blob/master/Microsoft.Toolkit.Uwp.UI.Controls/ImageEx/RoundImageEx.xaml) is the XAML template used in the toolkit for the default styling of the Control that has Corner Rounding.
## Platform Specific Notes
On Windows 10.0.16299.0 or higher, **CornerRadius** is supported on ImageEx. Use of this property will not cause an exception on downlevel platforms; however, the desired effect will not render.
## Requirements (Windows 10 Device Family)
| [Device family](http://go.microsoft.com/fwlink/p/?LinkID=526370) | Universal, 10.0.14393.0 or higher |

Просмотреть файл

@ -2,13 +2,16 @@
title: SlidableListItem XAML Control
author: nmetulev
ms.date: 08/20/2017
description: The SlideableListItem Control is a UI control that enables actions to be triggered by sliding the content left or right.
description: The SlidableListItem Control is a UI control that enables actions to be triggered by sliding the content left or right.
keywords: windows 10, uwp, uwp community toolkit, uwp toolkit, SlidableListItem, XAML Control, xaml
---
# SlidableListItem XAML Control
The **SlideableListItem Control** is a UI control that enables actions to be triggered by sliding the content left or right. This effect can be forced to ignore the mouse if only touch screen interaction is desired.
> [!NOTE]
The SlidableListItem is deprecated and will be removed in a future major release. Please use the [SwipeControl](https://docs.microsoft.com/en-us/windows/uwp/controls-and-patterns/swipe) available in the Fall Creators Update. Read the [Moving to SwipeControl](#swipe) section for more info.
The **SlidableListItem Control** is a UI control that enables actions to be triggered by sliding the content left or right. This effect can be forced to ignore the mouse if only touch screen interaction is desired.
This control can be used as a ListView Data Template root to create effects similar to those common in mobile email apps like Outlook.
@ -86,6 +89,30 @@ If you use **SlidableListItem** in a **ListView** with the **ItemClick** event,
```
## <a name="swipe"></a> Moving to SwipeControl
The Windows 10 Fall Creators Update SDK now includes the [SwipeControl](https://docs.microsoft.com/en-us/windows/uwp/controls-and-patterns/swipe) control among other new controls and APIs. This is great news for the UWP Community Toolkit as it means that one of its most popular controls has a comparable counterpart in the Windows SDK and it is very easy to transition to the SwipeControl if you are already using the SlidableListItem.
The SlidableListItem and SwipeControl share the same concepts and provide the same functionality. In fact, the SwipeControl adds even more functionality and can be used in even more scenarios.
### What developers need to know to move to the SwipeControl?
* **Two different modes:** The SwipeControl has two different modes of commanding:
* Execute mode - works the same way as the commanding on the SlidableListItem, where the user executes a command with a single swipe
* Reveal mode - the user swipes an item to open a menu where the commands can be executed by tapping them
* **Swipe direction:** SlidableListItem only supports left and right swiping while the SwipeControl supports all four directions (Up, Down, Left, Right)
* **SwipeItem:** The Fall Creators Update defines new objects to help define the swipe commands. Unlike the SlidableListItem where each command is defined through properties on the control itself, the SwipeControl accepts a collection of SwipeItems that define the commands. This is where you can specify properties such as background, foreground, icon, label, and invoked events.
### Making the transition easier
Starting with v2.1 of the UWP Community Toolkit, the SwipeControl provides a new property called **UseSwipeControlWhenPossible**. Setting the value to true will force the SlidableListItem to use a template based on the SwipeControl when running on the Fall Creators Update and above, and the regular template otherwise.
Using this property will enable you to take advantage of the SwipeControl on devices that supported it, while providing an experience based on SlidableListItem on devices that have not yet updated to the Fall Creators Update. Make sure to test the experience on multiple OS releases and plan to fully transition to the SwipeControl as the SlidableListItem will be removed from the UWP Community Toolkit in a future major release.
There are several SlidableListItem properties that have no effect when the SlidableListItem is using the SwipeControl:
* ActivationWidth
* IsOffsetLimited
* IsPointerReleasedOnSwipingHandled
* MouseSlidingEnabled
## Example Image
![SlidableListItem animation](../resources/images/Controls-SlidableListItem.gif "SlidableListItem")

Просмотреть файл

@ -46,6 +46,7 @@ Once you search you should see a list similar to the one below (versions may be
## <a name="supported"></a> Supported SDKs
* Anniversary Update (14393)
* Creators Update (15063)
* Fall Creators Update (16299)
## Features