Skip to content

Commit

Permalink
Merge pull request #2716 from MartinZikmund/dev/mazi/dropdownbutton
Browse files Browse the repository at this point in the history
feat: Add DropDownButton
  • Loading branch information
agneszitte authored Apr 16, 2020
2 parents a09904c + a549e87 commit 7e49bea
Show file tree
Hide file tree
Showing 12 changed files with 540 additions and 103 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 @@ -669,6 +669,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\DropDownButton\DropDownButtonPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\Flyout\Flyout_Unloaded.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down Expand Up @@ -3519,6 +3523,9 @@
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\ControlTests\Control_IsEnabled_Inheritance.xaml.cs">
<DependentUpon>Control_IsEnabled_Inheritance.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\DropDownButton\DropDownButtonPage.xaml.cs">
<DependentUpon>DropDownButtonPage.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\Flyout\FlyoutButtonViewModel.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\DatePicker\DatePickerFlyout_Unloaded.xaml.cs">
<DependentUpon>DatePickerFlyout_Unloaded.xaml</DependentUpon>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<!-- Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License. See LICENSE in the project root for license information. -->
<UserControl
x:Class="MUXControlsTestApp.DropDownButtonPage"
x:Name="DropDownButtonTestPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:MUXControlsTestApp"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:controls="using:Microsoft.UI.Xaml.Controls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Margin="12">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>

<ScrollViewer Grid.Column="0" Height="Auto">
<StackPanel Orientation="Vertical" VerticalAlignment="Top" Width="Auto" Height="Auto">
<TextBlock Text="Demo controls" Style="{ThemeResource StandardGroupHeader}" Margin="0"/>
<StackPanel Orientation="Horizontal" Margin="0,12,0,0">
<controls:DropDownButton CornerRadius="2" x:Name="TestDropDownButton" AutomationProperties.Name="TestDropDownButton" Content="Test Button" Click="TestDropDownButton_Click">
<controls:DropDownButton.Flyout>
<Flyout x:Name="TestFlyout" AutomationProperties.Name="TestFlyout" Placement="Bottom" Opened="TestDropDownButtonFlyout_Opened" Closed="TestDropDownButtonFlyout_Closed">
<TextBlock Text="Hello"/>
</Flyout>
</controls:DropDownButton.Flyout>
</controls:DropDownButton>

<Button Margin="6,0,0,0" Content="For Comparison">
<Button.Flyout>
<Flyout>
<TextBlock Text="Button flyout"/>
</Flyout>
</Button.Flyout>
</Button>
</StackPanel>


<TextBlock Text="Options" Style="{ThemeResource StandardGroupHeader}" Margin="0,16,0,8"/>
<CheckBox x:Name="SetFlyoutCheckbox" AutomationProperties.Name="SetFlyoutCheckbox" IsChecked="True"
Content="Flyout set" Checked="SetFlyoutCheckbox_Checked" Unchecked="SetFlyoutCheckbox_Unchecked"/>

<TextBlock Text="Status" Style="{ThemeResource StandardGroupHeader}" Margin="0,16,0,8"/>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>

<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>

<TextBlock Grid.Row="0">Click count:</TextBlock>
<TextBlock x:Name="ClickCountTextBlock" AutomationProperties.Name="ClickCountTextBlock"
Margin="4,0,0,0" Text="0" Grid.Row="0" Grid.Column="1"/>
<TextBlock Grid.Row="1">Flyout opened:</TextBlock>
<TextBlock x:Name="FlyoutOpenedCountTextBlock" AutomationProperties.Name="FlyoutOpenedCountTextBlock"
Margin="4,0,0,0" Text="0" Grid.Row="1" Grid.Column="1"/>
<TextBlock Grid.Row="2">Flyout closed:</TextBlock>
<TextBlock x:Name="FlyoutClosedCountTextBlock" AutomationProperties.Name="FlyoutClosedCountTextBlock"
Margin="4,0,0,0" Text="0" Grid.Row="2" Grid.Column="1"/>
</Grid>


</StackPanel>
</ScrollViewer>
</Grid>
</UserControl>
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

using System;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Markup;
using Windows.UI;
using System.Windows.Input;
using Uno.UI.Samples.Controls;

namespace MUXControlsTestApp
{

[SampleControlInfo("DropDownButton", "MUX Page")]
public sealed partial class DropDownButtonPage
{
private int _clickCount = 0;
private int _flyoutOpenedCount = 0;
private int _flyoutClosedCount = 0;

private Flyout _flyout;

public DropDownButtonPage()
{
this.InitializeComponent();

_flyout = new Flyout();
_flyout.Placement = FlyoutPlacementMode.Bottom;
TextBlock textBlock = new TextBlock();
textBlock.Text = "New Flyout";
_flyout.Content = textBlock;
_flyout.Opened += TestDropDownButtonFlyout_Opened;
_flyout.Closed += TestDropDownButtonFlyout_Closed;
}

private void TestDropDownButton_Click(object sender, object e)
{
ClickCountTextBlock.Text = (++_clickCount).ToString();
}

private void TestDropDownButtonFlyout_Opened(object sender, object e)
{
FlyoutOpenedCountTextBlock.Text = (++_flyoutOpenedCount).ToString();
}

private void TestDropDownButtonFlyout_Closed(object sender, object e)
{
FlyoutClosedCountTextBlock.Text = (++_flyoutClosedCount).ToString();
}

private void SetFlyoutCheckbox_Checked(object sender, RoutedEventArgs e)
{
if (TestDropDownButton != null && _flyout != null)
{
TestDropDownButton.Flyout = _flyout;
}
}

private void SetFlyoutCheckbox_Unchecked(object sender, RoutedEventArgs e)
{
if (TestDropDownButton != null)
{
TestDropDownButton.Flyout = null;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
#pragma warning disable 114 // new keyword hiding
namespace Windows.UI.Xaml.Automation
{
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __MACOS__
#if false || false || false || false || false
[global::Uno.NotImplemented]
#endif
public partial class ExpandCollapsePatternIdentifiers
{
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __MACOS__
#if false || false || false || false || false
[global::Uno.NotImplemented]
public static global::Windows.UI.Xaml.Automation.AutomationProperty ExpandCollapseStateProperty
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
#pragma warning disable 114 // new keyword hiding
namespace Windows.UI.Xaml.Controls
{
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __MACOS__
#if false || false || false || false || false
[global::Uno.NotImplemented]
#endif
public partial class DropDownButton : global::Windows.UI.Xaml.Controls.Button
{
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __MACOS__
#if false || false || false || false || false
[global::Uno.NotImplemented]
public DropDownButton() : base()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
#pragma warning disable 114 // new keyword hiding
namespace Windows.UI.Xaml.Controls
{
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __MACOS__
#if false || false || false || false || false
[global::Uno.NotImplemented]
#endif
public partial class DropDownButtonAutomationPeer : global::Windows.UI.Xaml.Automation.Peers.ButtonAutomationPeer,global::Windows.UI.Xaml.Automation.Provider.IExpandCollapseProvider
{
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __MACOS__
#if false || false || false || false || false
[global::Uno.NotImplemented]
public global::Windows.UI.Xaml.Automation.ExpandCollapseState ExpandCollapseState
{
Expand All @@ -17,7 +17,7 @@ public partial class DropDownButtonAutomationPeer : global::Windows.UI.Xaml.Aut
}
}
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __MACOS__
#if false || false || false || false || false
[global::Uno.NotImplemented]
public DropDownButtonAutomationPeer( global::Windows.UI.Xaml.Controls.DropDownButton owner) : base(owner)
{
Expand All @@ -26,14 +26,14 @@ public DropDownButtonAutomationPeer( global::Windows.UI.Xaml.Controls.DropDownBu
#endif
// Forced skipping of method Windows.UI.Xaml.Controls.DropDownButtonAutomationPeer.DropDownButtonAutomationPeer(Windows.UI.Xaml.Controls.DropDownButton)
// Forced skipping of method Windows.UI.Xaml.Controls.DropDownButtonAutomationPeer.ExpandCollapseState.get
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __MACOS__
#if false || false || false || false || false
[global::Uno.NotImplemented]
public void Collapse()
{
global::Windows.Foundation.Metadata.ApiInformation.TryRaiseNotImplemented("Windows.UI.Xaml.Controls.DropDownButtonAutomationPeer", "void DropDownButtonAutomationPeer.Collapse()");
}
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __MACOS__
#if false || false || false || false || false
[global::Uno.NotImplemented]
public void Expand()
{
Expand Down
Loading

0 comments on commit 7e49bea

Please sign in to comment.