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

Correctly propagate BindingContext to Border StrokeShape #13793

Merged
merged 18 commits into from
Mar 22, 2023
Merged

Conversation

jsuarezruiz
Copy link
Contributor

@jsuarezruiz jsuarezruiz commented Mar 9, 2023

Description of Change

This PR apply changes to correctly propagate the Border BindingContext to the StrokeShape.

Added a new sample in the Gallery where the Border StrokeShape bind the CornerRadius to the Border Width.
image
And unit test.
image

Issues Fixed

Fixes #13699
Fixes #13988

@jsuarezruiz jsuarezruiz added t/bug Something isn't working area-drawing Shapes, Borders, Shadows, Graphics, BoxView, custom drawing area-controls-border Border labels Mar 9, 2023
@ghost ghost added the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label Mar 9, 2023

if (strokeShape is VisualElement visualElement)
{
SetInheritedBindingContext(visualElement, BindingContext);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We were not propagating the BindingContext to the Shape used in the StrokeShape property or detecting changes to invalidate the Shape. These are the main changes.

Copy link
Member

Choose a reason for hiding this comment

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

Do we need Parent AND SetInheritedBindingContext? Does not setting Parent automatically set the binding context? I am not sure, so just checking... Does the order matter?

@github-actions
Copy link
Contributor

github-actions bot commented Mar 9, 2023

Thank you for your pull request. We are auto-formatting your source code to follow our code guidelines.

Copy link
Member

@mattleibow mattleibow left a comment

Choose a reason for hiding this comment

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

Nice! Just got a question on the propagation and the use of the new proxy types.


if (strokeShape is VisualElement visualElement)
{
SetInheritedBindingContext(visualElement, BindingContext);
Copy link
Member

Choose a reason for hiding this comment

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

Do we need Parent AND SetInheritedBindingContext? Does not setting Parent automatically set the binding context? I am not sure, so just checking... Does the order matter?

src/Controls/src/Core/Border.cs Outdated Show resolved Hide resolved
@github-actions
Copy link
Contributor

Thank you for your pull request. We are auto-formatting your source code to follow our code guidelines.

@jsuarezruiz
Copy link
Contributor Author

Added sample to validate #13988
fix-13988

propertyChanging: (bindable, oldvalue, newvalue) =>
{
if (newvalue is not null)
(bindable as Border)?.StopNotifyingStrokeShapeChanges();
Copy link
Member

Choose a reason for hiding this comment

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

Should this always fire? If I set a value and then null, this will not unsub.

Copy link
Member

Choose a reason for hiding this comment

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

If this is wrong, can we add a test for this?

propertyChanging: (bindable, oldvalue, newvalue) =>
{
if (newvalue is not null)
(bindable as Border)?.StopNotifyingStrokeChanges();
Copy link
Member

Choose a reason for hiding this comment

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

Same here, nothing ever unsubs.

}
Copy link
Member

Choose a reason for hiding this comment

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

Can we revert this whitespace change?

@rmarinho rmarinho merged commit 87fbdf3 into main Mar 22, 2023
@rmarinho rmarinho deleted the fix-13699 branch March 22, 2023 12:46
@github-actions github-actions bot locked and limited conversation to collaborators Dec 13, 2023
@Eilon Eilon removed the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label May 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-controls-border Border area-drawing Shapes, Borders, Shadows, Graphics, BoxView, custom drawing t/bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Border does not change rendering when modifying StrokeShape properties CornerRadius on Border in .net 7
7 participants