Skip to content

Commit

Permalink
feat(background_sizing): Added support for the BackgroundSizing Depen…
Browse files Browse the repository at this point in the history
…dencyProperty + a sample for it.
  • Loading branch information
carldebilly committed Aug 25, 2021
1 parent d712ce4 commit c3f8315
Show file tree
Hide file tree
Showing 18 changed files with 328 additions and 31 deletions.
7 changes: 7 additions & 0 deletions src/SamplesApp/UITests.Shared/UITests.Shared.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml\FrameworkElementTests\DynamicBackgroundSizing.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml\FrameworkElementTests\FrameworkElement_NativeLayout.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down Expand Up @@ -4775,6 +4779,9 @@
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml\FocusManager\Focus_FocusVisual_Properties.xaml.cs">
<DependentUpon>Focus_FocusVisual_Properties.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml\FrameworkElementTests\DynamicBackgroundSizing.xaml.cs">
<DependentUpon>DynamicBackgroundSizing.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml\FrameworkElementTests\FrameworkElement_NativeLayout.xaml.cs">
<DependentUpon>FrameworkElement_NativeLayout.xaml</DependentUpon>
</Compile>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,220 @@
<Page
x:Class="UITests.Windows_UI_Xaml.FrameworkElementTests.DynamicBackgroundSizing"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:UITests.Windows_UI_Xaml.FrameworkElementTests"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

<StackPanel Spacing="5" Margin="15">
<TextBlock FontSize="18">
This sample illustrate the difference background sizing options
</TextBlock>

<StackPanel Orientation="Horizontal" Spacing="10">
<ComboBox x:Name="dynamic" Header="Dynamic Sizing:">
<ComboBoxItem IsSelected="True">InnerBorderEdge</ComboBoxItem>
<ComboBoxItem>OuterBorderEdge</ComboBoxItem>
</ComboBox>
<ComboBox x:Name="radius" Header="CornerRadius:">
<ComboBoxItem IsSelected="True">0</ComboBoxItem>
<ComboBoxItem>10</ComboBoxItem>
<ComboBoxItem>20</ComboBoxItem>
</ComboBox>
</StackPanel>
<Grid ColumnSpacing="4" RowSpacing="4">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="50" />
<RowDefinition Height="50" />
<RowDefinition Height="50" />
<RowDefinition Height="50" />
<RowDefinition Height="50" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="50" />
<ColumnDefinition Width="50" />
<ColumnDefinition Width="50" />
<ColumnDefinition Width="50" />
</Grid.ColumnDefinitions>

<TextBlock Grid.Row="1">Border:</TextBlock>
<TextBlock Grid.Row="2">CntPresenter:</TextBlock>
<TextBlock Grid.Row="3">Grid:</TextBlock>
<TextBlock Grid.Row="4">RelPanel:</TextBlock>
<TextBlock Grid.Row="5">StackPanel:</TextBlock>

<TextBlock Grid.Column="1">Default</TextBlock>
<TextBlock Grid.Column="2">Inner</TextBlock>
<TextBlock Grid.Column="3">Outer</TextBlock>
<TextBlock Grid.Column="4">Dynamic</TextBlock>

<Border
Grid.Row="1"
Grid.Column="1"
Background="Green"
BorderBrush="#80FF0000"
BorderThickness="15" />

<Border
Grid.Row="1"
Grid.Column="2"
Background="Green"
BorderBrush="#80FF0000"
BorderThickness="15"
BackgroundSizing="InnerBorderEdge" />

<Border
Grid.Row="1"
Grid.Column="3"
Background="Green"
BorderBrush="#80FF0000"
BorderThickness="15"
BackgroundSizing="OuterBorderEdge"/>

<Border
Grid.Row="1"
Grid.Column="4"
Background="Green"
BorderBrush="#80FF0000"
BorderThickness="15"
CornerRadius="{Binding SelectedItem.Content, ElementName=radius}"
BackgroundSizing="{Binding SelectedItem.Content, ElementName=dynamic}"/>

<ContentPresenter
Grid.Row="2"
Grid.Column="1"
Background="Green"
BorderBrush="#80FF0000"
BorderThickness="15" />

<ContentPresenter
Grid.Row="2"
Grid.Column="2"
Background="Green"
BorderBrush="#80FF0000"
BorderThickness="15"
BackgroundSizing="InnerBorderEdge" />

<ContentPresenter
Grid.Row="2"
Grid.Column="3"
Background="Green"
BorderBrush="#80FF0000"
BorderThickness="15"
BackgroundSizing="OuterBorderEdge"/>

<ContentPresenter
Grid.Row="2"
Grid.Column="4"
Background="Green"
BorderBrush="#80FF0000"
BorderThickness="15"
CornerRadius="{Binding SelectedItem.Content, ElementName=radius}"
BackgroundSizing="{Binding SelectedItem.Content, ElementName=dynamic}"/>


<Grid
Grid.Row="3"
Grid.Column="1"
Background="Green"
BorderBrush="#80FF0000"
BorderThickness="15" />

<Grid
Grid.Row="3"
Grid.Column="2"
Background="Green"
BorderBrush="#80FF0000"
BorderThickness="15"
BackgroundSizing="InnerBorderEdge" />

<Grid
Grid.Row="3"
Grid.Column="3"
Background="Green"
BorderBrush="#80FF0000"
BorderThickness="15"
BackgroundSizing="OuterBorderEdge"/>

<Grid
Grid.Row="3"
Grid.Column="4"
Background="Green"
BorderBrush="#80FF0000"
BorderThickness="15"
CornerRadius="{Binding SelectedItem.Content, ElementName=radius}"
BackgroundSizing="{Binding SelectedItem.Content, ElementName=dynamic}"/>


<RelativePanel
Grid.Row="4"
Grid.Column="1"
Background="Green"
BorderBrush="#80FF0000"
BorderThickness="15" />

<RelativePanel
Grid.Row="4"
Grid.Column="2"
Background="Green"
BorderBrush="#80FF0000"
BorderThickness="15"
BackgroundSizing="InnerBorderEdge" />

<RelativePanel
Grid.Row="4"
Grid.Column="3"
Background="Green"
BorderBrush="#80FF0000"
BorderThickness="15"
BackgroundSizing="OuterBorderEdge"/>

<RelativePanel
Grid.Row="4"
Grid.Column="4"
Background="Green"
BorderBrush="#80FF0000"
BorderThickness="15"
CornerRadius="{Binding SelectedItem.Content, ElementName=radius}"
BackgroundSizing="{Binding SelectedItem.Content, ElementName=dynamic}"/>


<StackPanel
Grid.Row="5"
Grid.Column="1"
Background="Green"
BorderBrush="#80FF0000"
BorderThickness="15" />

<StackPanel
Grid.Row="5"
Grid.Column="2"
Background="Green"
BorderBrush="#80FF0000"
BorderThickness="15"
BackgroundSizing="InnerBorderEdge" />

<StackPanel
Grid.Row="5"
Grid.Column="3"
Background="Green"
BorderBrush="#80FF0000"
BorderThickness="15"
BackgroundSizing="OuterBorderEdge"/>

<StackPanel
Grid.Row="5"
Grid.Column="4"
Background="Green"
BorderBrush="#80FF0000"
BorderThickness="15"
CornerRadius="{Binding SelectedItem.Content, ElementName=radius}"
BackgroundSizing="{Binding SelectedItem.Content, ElementName=dynamic}"/>
</Grid>

</StackPanel>
</Page>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Windows.UI.Xaml.Controls;
using Uno.UI.Samples.Controls;

namespace UITests.Windows_UI_Xaml.FrameworkElementTests
{
[Sample("FrameworkElement")]
public sealed partial class DynamicBackgroundSizing : Page
{
public DynamicBackgroundSizing()
{
this.InitializeComponent();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ private void ProcessType(INamedTypeSymbol typeSymbol)
builder.AppendLineInvariant($"using Uno.UI;");
builder.AppendLineInvariant($"using Uno.UI.DataBinding;");
builder.AppendLineInvariant($"using Windows.UI.Xaml;");
builder.AppendLineInvariant($"using Windows.UI.Xaml.Controls;");
builder.AppendLineInvariant($"using Windows.UI.Xaml.Data;");
builder.AppendLineInvariant($"using Uno.Diagnostics.Eventing;");

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public partial class Border : global::Windows.UI.Xaml.FrameworkElement
}
}
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public global::Windows.UI.Xaml.Controls.BackgroundSizing BackgroundSizing
{
Expand All @@ -48,7 +48,7 @@ public partial class Border : global::Windows.UI.Xaml.FrameworkElement
// Skipping already declared property ChildTransitionsProperty
// Skipping already declared property CornerRadiusProperty
// Skipping already declared property PaddingProperty
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public static global::Windows.UI.Xaml.DependencyProperty BackgroundSizingProperty { get; } =
Windows.UI.Xaml.DependencyProperty.Register(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public double LineHeight
}
}
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public global::Windows.UI.Xaml.Controls.BackgroundSizing BackgroundSizing
{
Expand Down Expand Up @@ -225,7 +225,7 @@ public double LineHeight
// Skipping already declared property PaddingProperty
// Skipping already declared property TextWrappingProperty
// Skipping already declared property VerticalContentAlignmentProperty
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public static global::Windows.UI.Xaml.DependencyProperty BackgroundSizingProperty { get; } =
Windows.UI.Xaml.DependencyProperty.Register(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ public bool Is
}
}
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public global::Windows.UI.Xaml.Controls.BackgroundSizing BackgroundSizing
{
Expand Down Expand Up @@ -429,7 +429,7 @@ public bool Is
typeof(global::Windows.UI.Xaml.Controls.Control),
new FrameworkPropertyMetadata(default(global::Windows.UI.Xaml.CornerRadius)));
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public static global::Windows.UI.Xaml.DependencyProperty BackgroundSizingProperty { get; } =
Windows.UI.Xaml.DependencyProperty.Register(
Expand Down
4 changes: 2 additions & 2 deletions src/Uno.UI/Generated/3.0.0.0/Windows.UI.Xaml.Controls/Grid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public partial class Grid : global::Windows.UI.Xaml.Controls.Panel
// Skipping already declared property BorderBrush
// Skipping already declared property RowSpacing
// Skipping already declared property ColumnSpacing
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public global::Windows.UI.Xaml.Controls.BackgroundSizing BackgroundSizing
{
Expand All @@ -39,7 +39,7 @@ public partial class Grid : global::Windows.UI.Xaml.Controls.Panel
// Skipping already declared property PaddingProperty
// Skipping already declared property ColumnSpacingProperty
// Skipping already declared property RowSpacingProperty
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public static global::Windows.UI.Xaml.DependencyProperty BackgroundSizingProperty { get; } =
Windows.UI.Xaml.DependencyProperty.Register(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public partial class RelativePanel : global::Windows.UI.Xaml.Controls.Panel
// Skipping already declared property CornerRadius
// Skipping already declared property BorderThickness
// Skipping already declared property BorderBrush
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public global::Windows.UI.Xaml.Controls.BackgroundSizing BackgroundSizing
{
Expand Down Expand Up @@ -45,7 +45,7 @@ public partial class RelativePanel : global::Windows.UI.Xaml.Controls.Panel
// Skipping already declared property LeftOfProperty
// Skipping already declared property PaddingProperty
// Skipping already declared property RightOfProperty
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public static global::Windows.UI.Xaml.DependencyProperty BackgroundSizingProperty { get; } =
Windows.UI.Xaml.DependencyProperty.Register(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public bool AreScrollSnapPointsRegular
// Skipping already declared property BorderThickness
// Skipping already declared property BorderBrush
// Skipping already declared property Spacing
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public global::Windows.UI.Xaml.Controls.BackgroundSizing BackgroundSizing
{
Expand All @@ -47,7 +47,7 @@ public bool AreScrollSnapPointsRegular
// Skipping already declared property CornerRadiusProperty
// Skipping already declared property PaddingProperty
// Skipping already declared property SpacingProperty
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public static global::Windows.UI.Xaml.DependencyProperty BackgroundSizingProperty { get; } =
Windows.UI.Xaml.DependencyProperty.Register(
Expand Down
Loading

0 comments on commit c3f8315

Please sign in to comment.