Skip to content

Commit

Permalink
Initial port of code from TransitionHelper PR CommunityToolkit/Window…
Browse files Browse the repository at this point in the history
…sCommunityToolkit#4338

(Still not compiling)
  • Loading branch information
michael-hawker committed Jan 10, 2023
1 parent 4b607d7 commit a65b8b3
Show file tree
Hide file tree
Showing 37 changed files with 2,434 additions and 682 deletions.
2 changes: 1 addition & 1 deletion Windows.Toolkit.Common.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<Copyright>(c) .NET Foundation and Contributors. All rights reserved.</Copyright>
<PackageProjectUrl>https://github.com/CommunityToolkit/Labs-Windows</PackageProjectUrl>
<PackageReleaseNotes>https://github.com/CommunityToolkit/Labs-Windows/releases</PackageReleaseNotes>
<PackageIcon>Icon.png</PackageIcon>
<!--<PackageIcon>Icon.png</PackageIcon>-->
<PackageIconUrl>https://raw.githubusercontent.com/CommunityToolkit/Labs-Windows/main/nuget.png</PackageIconUrl>
<!-- TODO: Remove when closing https://github.com/CommunityToolkit/Labs-Windows/issues/256 -->
<NoWarn>$(NoWarn);NU1505;NU1504</NoWarn>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Numerics;
using Microsoft.Toolkit.Uwp.UI;
using Microsoft.Toolkit.Uwp.UI.Animations.Helpers;

namespace TransitionHelperExperiment.Samples;

public sealed class CustomTextScalingCalculator : IScalingCalculator
{
/// <inheritdoc/>
public Vector2 GetScaling(UIElement source, UIElement target)
{
var sourceTextElement = source?.FindDescendantOrSelf<TextBlock>();
var targetTextElement = target?.FindDescendantOrSelf<TextBlock>();
if (sourceTextElement is not null && targetTextElement is not null)
{
var scale = targetTextElement.FontSize / sourceTextElement.FontSize;
return new Vector2((float)scale);
}

return new Vector2(1);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,34 @@
<RootNamespace>TransitionHelperExperiment.Samples</RootNamespace>
<AssemblyName>TransitionHelperExperiment.Samples</AssemblyName>
</PropertyGroup>

<ItemGroup>
<Compile Remove="CustomTextScalingCalculator.cs" />
<Compile Remove="TransitionHelperFullExample.xaml.cs" />
</ItemGroup>

<ItemGroup>
<Content Remove="TransitionHelperFullExample.xaml" />
</ItemGroup>

<ItemGroup>
<None Remove="TransitionHelperFullExample.xaml" />
</ItemGroup>

<ItemGroup>
<UpToDateCheckInput Remove="TransitionHelperFullExample.xaml" />
</ItemGroup>

<!-- Sample XAML Pages and Markdown files are automatically included, and don't need to be specified here. -->

<ItemGroup>
<ProjectReference Include="..\..\src\CommunityToolkit.Labs.WinUI.TransitionHelper.csproj" />
</ItemGroup>

<ItemGroup>
<Page Update="TransitionHelperFullExample.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: TransitionHelper
author: githubaccount
description: TODO: Your experiment's description here
description: An animation helper that morphs between two controls.
keywords: TransitionHelper, Control, Layout
dev_langs:
- csharp
Expand All @@ -11,54 +11,11 @@ discussion-id: 0
issue-id: 0
---

<!-- To know about all the available Markdown syntax, Check out https://docs.microsoft.com/contribute/markdown-reference -->
<!-- Ensure you remove all comments before submission, to ensure that there are no formatting issues when displaying this page. -->
<!-- It is recommended to check how the Documentation will look in the sample app, before Merging a PR -->
<!-- **Note:** All links to other docs.microsoft.com pages should be relative without locale, i.e. for the one above would be /contribute/markdown-reference -->
<!-- Included images should be optimized for size and not include any Intellectual Property references. -->

<!-- Be sure to update the discussion/issue numbers above with your Labs discussion/issue id numbers in order for UI links to them from the sample app to work. -->

# TransitionHelper

TODO: Fill in information about this experiment and how to get started here...

## Custom Control

You can inherit from an existing component as well, like `Panel`, this example shows a control without a
XAML Style that will be more light-weight to consume by an app developer:

> [!Sample TransitionHelperCustomSample]
## Templated Controls

The Toolkit is built with templated controls. This provides developers a flexible way to restyle components
easily while still inheriting the general functionality a control provides. The examples below show
how a component can use a default style and then get overridden by the end developer.

TODO: Two types of templated control building methods are shown. Delete these if you're building a custom component.
Otherwise, pick one method for your component and delete the files related to the unchosen `_ClassicBinding` or `_xBind`
classes (and the custom non-suffixed one as well). Then, rename your component to just be your component name.

The `_ClassicBinding` class shows the traditional method used to develop components with best practices.

### Implict style

> [!SAMPLE TransitionHelperTemplatedSample]
### Custom style

> [!SAMPLE TransitionHelperTemplatedStyleCustomSample]
## Templated Controls with x:Bind

This is an _experimental_ new way to define components which allows for the use of x:Bind within the style.

### Implict style

> [!SAMPLE TransitionHelperXbindBackedSample]
An animation helper that morphs between two controls.

### Custom style
### Example

> [!SAMPLE TransitionHelperXbindBackedStyleCustomSample]
> [!SAMPLE TransitionHelperFullExample]

This file was deleted.

This file was deleted.

Loading

0 comments on commit a65b8b3

Please sign in to comment.