-
Notifications
You must be signed in to change notification settings - Fork 747
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2716 from MartinZikmund/dev/mazi/dropdownbutton
feat: Add DropDownButton
- Loading branch information
Showing
12 changed files
with
540 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
...SamplesApp/UITests.Shared/Windows_UI_Xaml_Controls/DropDownButton/DropDownButtonPage.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
70 changes: 70 additions & 0 deletions
70
...plesApp/UITests.Shared/Windows_UI_Xaml_Controls/DropDownButton/DropDownButtonPage.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.