Open VincentH-Net opened 2 years ago
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)
);
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
Is there no support for
VisualStateManager
?Originally posted by @YegorStepanov in https://github.com/VincentH-Net/CSharpForMarkup/issues/19#issuecomment-1000878827