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

PersonPictureSettings API review #13

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions api_review/personpicture/PersonPictureAPI.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Background

Xaml controls are typically implemented using an element tree that’s defined in a template.
For example the template for a ComboBox control has a TextBlock in it to display the selected value.

Several controls have properties that are only expected to be useful to these templates,
and so there’s a common pattern for the control to expose them in a TemplateSettings property.
For example [ComboBox.TemplateSettings](https://docs.microsoft.com/en-us/uwp/api/Windows.UI.Xaml.Controls.ComboBox.TemplateSettings)
is used by the ComboBox’s template. See [this doc page](https://docs.microsoft.com/en-us/windows/uwp/xaml-platform/template-settings-classes) for more details.

This API update introduces this pattern to the PersonPicture control:
a new TemplateSettings property and associated PersonPictureTemplateSettings class.

# Description

Provides calculated values that can be referenced as TemplatedParent sources when defining templates
for a PersonPicture control. Not intended for general use.

# API Details

```
namespace Microsoft.UI.Xaml.Controls
{
[webhosthidden]
unsealed runtimeclass PersonPicture : Windows.UI.Xaml.Controls.Control
{
...

PersonPictureTemplateSettings TemplateSettings { get; };

...
}

[webhosthidden]
runtimeclass PersonPictureTemplateSettings : Windows.UI.Xaml.DependencyObject
{
String ActualInitials { get; };
Windows.UI.Xaml.Media.ImageBrush ActualImageBrush { get; };
}

}
```

# Examples

This is intended for use in the style of the `PersonPicture` control. Sample usage:

```xaml
<Style TargetType="local:PersonPicture">
...
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="local:PersonPicture">
<Grid x:Name="RootGrid">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<!-- Visual State when a Photo is available for display -->
<VisualState x:Name="Photo">
<VisualState.Setters>
<Setter Target="PersonPictureEllipse.Fill" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.ActualImageBrush}"/>
</VisualState.Setters>
</VisualState>
...
<TextBlock
...
Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.ActualInitials}" />

```

# API Notes

## Class: PersonPicture
| Member Name | Description |
|:- |:--|
| TemplateSettings | Provides calculated values that can be referenced as TemplatedParent sources when defining templates for a PersonPicture control. Not intended for general use. |

## Class: PersonPictureTemplateSettings
| Member Name | Description |
|:- |:--|
| ActualInitials | The initials that should be displayed in the control. Empty when an image is specified or when the PersonPicture control represents a group. |
| ActualImageBrush | The image brush to use in the control. The PersonPicture control determines which image to use based on how it was configured. This property will be null when no image should be displayed. |