Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support VisualStateManager #22

Open
VincentH-Net opened this issue Dec 25, 2021 · 2 comments
Open

Support VisualStateManager #22

VincentH-Net opened this issue Dec 25, 2021 · 2 comments
Labels
winui CSharpMarkup.WinUI

Comments

@VincentH-Net
Copy link
Owner

Is there no support for VisualStateManager?

image

Originally posted by @YegorStepanov in #19 (comment)

@VincentH-Net VincentH-Net added the winui CSharpMarkup.WinUI label Jan 6, 2022
@VincentH-Net
Copy link
Owner Author

VincentH-Net commented Apr 7, 2022

The C# API for VSM is mostly implemented, although there is still some polishing todo. There is still an issue to getting an example working.

Example:

    static ControlTemplate LikeButton => ControlTemplate(() =>
        Grid (
            Rectangle().Name("RedRectangle"),
            ContentPresenter().Center()
        )  .VisualStateGroups(
                VisualStateGroup("CheckStates",
                    VisualState("Checked", Storyboard(DoubleAnimation(0.1, 1.0, 0.5).Storyboard_TargetName("RedRectangle").Storyboard_TargetProperty("Opacity"))),
                    VisualState("Unchecked"),
                    VisualState("Indeterminate")
                )
            ), typeof(ToggleButton)
    );

@VincentH-Net
Copy link
Owner Author

At the moment the Windows App SDK (1.4) does not expose the necessary API's to C# to use VisualStateManager. A key blocker is that no x:Name can be set from C# - see this Windows App SDK discussion

A workaround for C# Markup for WinUI and Uno is to use VisualStateManager from a XAML resource - see this example C# Markup, which uses this XAML resource to animate a Button using the VisualStateManager

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
winui CSharpMarkup.WinUI
Projects
None yet
Development

No branches or pull requests

1 participant