-
Notifications
You must be signed in to change notification settings - Fork 41
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
CornerRadius related APIs #48
base: master
Are you sure you want to change the base?
Conversation
* Add CornerRadiusFilterConverter api doc * Apply suggestions from code review Co-Authored-By: Yulia Klein <[email protected]> * Spec formatting/info updates (#46) More background info, reorder sections, use ControlTemplate for the example code. * Added enum property * Add attached property spec * cr feedback * Combined specs and added some background
|
||
But there are cases where the ControlTemplate needs to get only some of the components out of the CornerRadius struct, for example the top left and right corners, in order to have a rounded top and a square bottom. There's no way to create a TemplateBinding to a struct field, so you can't bind to CornerRadius.TopLeft. | ||
|
||
For example when CommandBarFlyout opens up its secondary menu, primary and secondary menus are clipped together we need to clear rounded corners on bottom of primary menu and top of secondary menu to close the gaps. The following shows circles on the rounded corners and squares on the squared corners: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lots of inside baseball in this paragraph. I think this translates into
For example, when the CommandBarFlyout opens up its secondary menu, the secondary menu is placed adjacent to the primary menu. To make the secondary menu appear to be an extension of the primary menu, we need to remove the rounded corners from the bottom of the primary menu and the top of the secondary menu (green squares). On the other hand, the top corners of the primary menu and bottom corners of the secondary menu remain rounded (red circles).
|
||
![CommandBarFlyout CornerRadius example](images/commandbarflyout-cornerradius-example.png) | ||
|
||
The solution in this spec is a stock IValueConverter that can be used with the TemplateBinding to extract fields out of the struct. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"extract fields out of the struct" is confusing, because it sounds like it's a converter that takes a CornerRadius
and returns the value of a specific field. Perhaps
This spec provides a
CornerRadiusFilterConverter
which retains the corner radius on selected corners, while converting the other corners to square corners. For example, settingFilter="Top"
causes theCornerRadiusFilter
to preserve the corner radius for theTopLeft
andTopRight
corners, while setting theBottomLeft
andBottomRight
corner radii to zero, thereby making them square.
# Description | ||
|
||
## CornerRadiusFilterConverter class | ||
Use the CornerRadiusFilterConverter with a Binding or TemplateBinding to create a new CornerRadius struct from an existing one, extracting only some of the fields, leaving the others zero. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think "extracting" should be "preserving". The word "extracting" suggests that the value is "extracted from" the source, and treated as the extracted value. E.g.
Height="{Binding CornerRadius, Converter={StaticResource TopLeftCornerFilter}}"
This takes the CornerRadius
, extracts the top left corner (producing a Double
) and sets that as the Height
.
But that's not what this does. This takes the extracted values, then re-creates a new CornerRadius
from them.
Use the CornerRadiusFilterConverter with a Binding or TemplateBinding to create a new CornerRadius struct from an existing one, extracting only some of the fields, leaving the others zero. | ||
|
||
## AutoSuggestBoxHelper/ComboBoxHelper KeepInteriorCornersSquare property | ||
Set this property on an AutoSuggestBox/ComboBox to keep the interior corners square, even if the CornerRadius property is non zero. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Took me a while to figure out that the "interior corners" are the bottom corners of the fixed portion + the top corners of the dropdown portion. May want state this explicitly.
If the AutoSuggestBox/ComboBox
KeepInteriorCornersSquare
property isTrue
, then the bottom corners of the fixed portion of the control and the top corners of the drop-down list are made square, even if theCornerRadius
property is nonzero.
Top, | ||
Right, | ||
Left, | ||
Bottom |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't this be better as
[webhosthidden]
[flags]
public enum CornerRadiusFilterCorners
{
TopLeft = 0x0001,
TopRight = 0x0002,
BottomLeft = 0x0004,
BottomRight = 0x0008,
Top = TopLeft | TopRight,
Left = TopLeft | BottomLeft,
Bottom = BottomLeft | BottomRight,
Right = TopRight | BottomRight,
}
That would let met write not only
<CornerRadiusFilterConverter Corners="Top" x:Name="TopCornerFilter" />
but also
<CornerRadiusFilterConverter Corners="TopLeft,TopRight,BottomRight" x:Name="CartoonBalloonCornerFilter" />
<CornerRadiusFilterConverter Corners="TopLeft,BottomRight" x:Name="TiaaLogoCornerFilter" />
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We saw some issues that values like "TopLeft,TopRight,BottomRight"
are not evaluated correctly in CX app. (See this comment microsoft/microsoft-ui-xaml#1252 (comment).) So we can't really do this right now. I've filed a bug on markup.
No description provided.