Skip to content

Conversation

@ne0rrmatrix
Copy link
Member

Description of Change

Refactored Views to define bindable properties using the [BindableProperty] attribute and partial properties. Removed manual BindableProperty fields and wrappers, specifying default values and value creators via attributes and static methods. Updated property summaries for clarity. This simplifies and modernizes the property implementation.

PR Checklist

  • Has a linked Issue, and the Issue has been approved(bug) or Championed (feature/proposal)
  • Has tests (if omitted, state reason in description)
  • Has samples (if omitted, state reason in description)
  • Rebased on top of main at time of PR
  • Changes adhere to coding standard
  • Documentation created or updated: https://github.com/MicrosoftDocs/CommunityToolkit/pulls

Additional information

Copy link
Collaborator

@TheCodeTraveler TheCodeTraveler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks James!

Could you also please create a [ClassName]Defaults.shared.cs class for each of these Views in CommunityToolkit.Maui.Core/Defaults/ and also add a Unit Test for each called EnsureDefaults that verifies the default value for each property in the class equals the expected default value?

Here's an example that I added for FadeAnimation in the recent PR:

static class FadeAnimationDefaults
{
public const uint Length = 300u;
public const double Opacity = 0.3;
}

[Fact]
public void EnsureDefaults()
{
// Arrange
var animation = new FadeAnimation();
// Act // Assert
Assert.Equal(BaseAnimationDefaults.Easing, animation.Easing);
Assert.Equal(FadeAnimationDefaults.Length, animation.Length);
Assert.Equal(FadeAnimationDefaults.Opacity, animation.Opacity);
}

We should've created the [ClassName]Defaults.shared.cs and implemented these unit tests when originally creating every control in CommunityToolkit.Maui. But now that we're going back and editing every control to implement [BindableProperty], I've found that this is a great time to clean up our codebase and implement these!

@ne0rrmatrix
Copy link
Member Author

Thanks James!

Could you also please create a [ClassName]Defaults.shared.cs class for each of these Views in CommunityToolkit.Maui.Core/Defaults/ and also add a Unit Test for each called EnsureDefaults that verifies the default value for each property in the class equals the expected default value?

Here's an example that I added for FadeAnimation in the recent PR:

static class FadeAnimationDefaults
{
public const uint Length = 300u;
public const double Opacity = 0.3;
}

[Fact]
public void EnsureDefaults()
{
// Arrange
var animation = new FadeAnimation();
// Act // Assert
Assert.Equal(BaseAnimationDefaults.Easing, animation.Easing);
Assert.Equal(FadeAnimationDefaults.Length, animation.Length);
Assert.Equal(FadeAnimationDefaults.Opacity, animation.Opacity);
}

We should've created the [ClassName]Defaults.shared.cs and implemented these unit tests when originally creating every control in CommunityToolkit.Maui. But now that we're going back and editing every control to implement [BindableProperty], I've found that this is a great time to clean up our codebase and implement these!

I will update the classes as requested. This seems like a logical next step. Getting excited with all the changes. This has been fun to do so far :)

Copy link
Collaborator

@TheCodeTraveler TheCodeTraveler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks James!

@TheCodeTraveler TheCodeTraveler merged commit 50fa459 into CommunityToolkit:main Dec 21, 2025
10 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Dec 22, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants