-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b5588a1
commit 4222a7e
Showing
42 changed files
with
1,400 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.12.35323.107 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TitleBarDemo", "TitleBarDemo\TitleBarDemo.csproj", "{518139CB-8E6C-427D-B3B9-90381CAF288B}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{518139CB-8E6C-427D-B3B9-90381CAF288B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{518139CB-8E6C-427D-B3B9-90381CAF288B}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{518139CB-8E6C-427D-B3B9-90381CAF288B}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{518139CB-8E6C-427D-B3B9-90381CAF288B}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {91AE70EC-640C-42BB-B9F6-81D6C209BA80} | ||
EndGlobalSection | ||
EndGlobal |
14 changes: 14 additions & 0 deletions
14
9.0/UserInterface/Views/TitleBarDemo/TitleBarDemo/App.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,14 @@ | ||
<?xml version = "1.0" encoding = "UTF-8" ?> | ||
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:local="clr-namespace:TitleBarDemo" | ||
x:Class="TitleBarDemo.App"> | ||
<Application.Resources> | ||
<ResourceDictionary> | ||
<ResourceDictionary.MergedDictionaries> | ||
<ResourceDictionary Source="Resources/Styles/Colors.xaml" /> | ||
<ResourceDictionary Source="Resources/Styles/Styles.xaml" /> | ||
</ResourceDictionary.MergedDictionaries> | ||
</ResourceDictionary> | ||
</Application.Resources> | ||
</Application> |
15 changes: 15 additions & 0 deletions
15
9.0/UserInterface/Views/TitleBarDemo/TitleBarDemo/App.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,15 @@ | ||
namespace TitleBarDemo | ||
{ | ||
public partial class App : Application | ||
{ | ||
public App() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
protected override Window CreateWindow(IActivationState? activationState) | ||
{ | ||
return new MainWindow(); | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
9.0/UserInterface/Views/TitleBarDemo/TitleBarDemo/AppShell.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,13 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<Shell x:Class="TitleBarDemo.AppShell" | ||
xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:local="clr-namespace:TitleBarDemo" | ||
Shell.FlyoutBehavior="Disabled" | ||
Title="TitleBarDemo"> | ||
|
||
<ShellContent Title="Home" | ||
ContentTemplate="{DataTemplate local:MainPage}" | ||
Route="MainPage" /> | ||
|
||
</Shell> |
9 changes: 9 additions & 0 deletions
9
9.0/UserInterface/Views/TitleBarDemo/TitleBarDemo/AppShell.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,9 @@ | ||
namespace TitleBarDemo; | ||
|
||
public partial class AppShell : Shell | ||
{ | ||
public AppShell() | ||
{ | ||
InitializeComponent(); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
9.0/UserInterface/Views/TitleBarDemo/TitleBarDemo/BaseViewModel.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,28 @@ | ||
using System.ComponentModel; | ||
using System.Runtime.CompilerServices; | ||
|
||
namespace TitleBarDemo; | ||
|
||
public abstract class BaseViewModel : INotifyPropertyChanged | ||
{ | ||
protected bool SetProperty<T>(ref T backingStore, T value, [CallerMemberName] string propertyName = "", Action? onChanged = null) | ||
{ | ||
if (EqualityComparer<T>.Default.Equals(backingStore, value)) | ||
return false; | ||
|
||
backingStore = value; | ||
onChanged?.Invoke(); | ||
OnPropertyChanged(propertyName); | ||
return true; | ||
} | ||
|
||
#region INotifyPropertyChanged | ||
|
||
public event PropertyChangedEventHandler? PropertyChanged; | ||
protected void OnPropertyChanged([CallerMemberName] string propertyName = "") | ||
{ | ||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); | ||
} | ||
|
||
#endregion | ||
} |
98 changes: 98 additions & 0 deletions
98
9.0/UserInterface/Views/TitleBarDemo/TitleBarDemo/MainPage.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,98 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
x:Class="TitleBarDemo.MainPage"> | ||
|
||
<Grid ColumnDefinitions="*,*"> | ||
<VerticalStackLayout Spacing="16" | ||
Margin="16" | ||
Grid.Column="0"> | ||
<Label Text="Content Options" | ||
FontSize="24" /> | ||
<HorizontalStackLayout> | ||
<CheckBox x:Name="SetIconCheckBox" | ||
IsChecked="False" | ||
CheckedChanged="SetIconCheckBox_CheckedChanged" /> | ||
<Label Text="Set Icon" | ||
VerticalOptions="Center" /> | ||
</HorizontalStackLayout> | ||
|
||
<Entry x:Name="TitleTextBox" | ||
Placeholder="Title Text" | ||
HorizontalOptions="Start" | ||
Text="{Binding Title, Mode=TwoWay}" | ||
WidthRequest="120" /> | ||
<Entry x:Name="SubtitleTextBox" | ||
Placeholder="Subtitle Text" | ||
HorizontalOptions="Start" | ||
Text="{Binding Subtitle, Mode=TwoWay}" | ||
WidthRequest="120" /> | ||
|
||
<HorizontalStackLayout> | ||
<CheckBox x:Name="LeadingContentCheckBox" | ||
IsChecked="False" | ||
CheckedChanged="LeadingCheckBox_CheckedChanged" /> | ||
<Label Text="Leading Content" | ||
VerticalOptions="Center" /> | ||
</HorizontalStackLayout> | ||
|
||
<HorizontalStackLayout> | ||
<CheckBox x:Name="ContentCheckBox" | ||
IsChecked="True" | ||
CheckedChanged="ContentCheckBox_CheckedChanged" /> | ||
<Label Text="Content" | ||
VerticalOptions="Center" /> | ||
</HorizontalStackLayout> | ||
|
||
<HorizontalStackLayout> | ||
<CheckBox x:Name="TrailingContentCheckBox" | ||
IsChecked="False" | ||
CheckedChanged="TrailingCheckBox_CheckedChanged" /> | ||
<Label Text="Trailing Content" | ||
VerticalOptions="Center" /> | ||
</HorizontalStackLayout> | ||
|
||
<HorizontalStackLayout> | ||
<CheckBox x:Name="TallModeCheckBox" | ||
IsChecked="True" | ||
CheckedChanged="TallModeCheckBox_CheckedChanged" /> | ||
<Label Text="Tall TitleBar" | ||
VerticalOptions="Center" /> | ||
</HorizontalStackLayout> | ||
|
||
<HorizontalStackLayout> | ||
<CheckBox IsChecked="{Binding ShowTitleBar, Mode=TwoWay}" /> | ||
<Label Text="Show TitleBar" | ||
VerticalOptions="Center" /> | ||
</HorizontalStackLayout> | ||
</VerticalStackLayout> | ||
|
||
<VerticalStackLayout Spacing="16" | ||
Margin="16" | ||
Grid.Column="1"> | ||
<Label Text="Color Options" | ||
FontSize="24" /> | ||
|
||
<HorizontalStackLayout Spacing="8"> | ||
<Entry x:Name="ColorTextBox" | ||
Placeholder="Green" | ||
HorizontalOptions="Start" | ||
WidthRequest="120" /> | ||
<Button x:Name="ColorButton" | ||
Text="Set Color" | ||
Clicked="ColorButton_Clicked" /> | ||
</HorizontalStackLayout> | ||
|
||
<HorizontalStackLayout Spacing="8"> | ||
<Entry x:Name="ForegroundColorTextBox" | ||
Placeholder="Green" | ||
HorizontalOptions="Start" | ||
WidthRequest="120" /> | ||
<Button x:Name="ForegroundColorButton" | ||
Text="Set Foreground Color" | ||
Clicked="ForegroundColorButton_Clicked" /> | ||
</HorizontalStackLayout> | ||
</VerticalStackLayout> | ||
</Grid> | ||
|
||
</ContentPage> |
120 changes: 120 additions & 0 deletions
120
9.0/UserInterface/Views/TitleBarDemo/TitleBarDemo/MainPage.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,120 @@ | ||
using Microsoft.Maui.Controls.Shapes; | ||
|
||
namespace TitleBarDemo | ||
{ | ||
public partial class MainPage : ContentPage | ||
{ | ||
TitleBar? _customTitleBar; | ||
|
||
public MainPage() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
protected override void OnAppearing() | ||
{ | ||
base.OnAppearing(); | ||
_customTitleBar = Window.TitleBar as TitleBar; | ||
} | ||
|
||
private void SetIconCheckBox_CheckedChanged(object sender, CheckedChangedEventArgs e) | ||
{ | ||
if (e.Value) | ||
{ | ||
_customTitleBar!.Icon = "tb_appicon.png"; | ||
} | ||
else | ||
{ | ||
_customTitleBar!.Icon = string.Empty; | ||
} | ||
} | ||
|
||
private void ColorButton_Clicked(object sender, EventArgs e) | ||
{ | ||
if (Color.TryParse(ColorTextBox.Text, out var color)) | ||
{ | ||
_customTitleBar!.BackgroundColor = color; | ||
} | ||
} | ||
|
||
private void ForegroundColorButton_Clicked(object sender, EventArgs e) | ||
{ | ||
if (Color.TryParse(ForegroundColorTextBox.Text, out var color)) | ||
{ | ||
_customTitleBar!.ForegroundColor = color; | ||
} | ||
} | ||
|
||
private void LeadingCheckBox_CheckedChanged(object sender, CheckedChangedEventArgs e) | ||
{ | ||
if (e.Value) | ||
{ | ||
_customTitleBar!.LeadingContent = new Button() | ||
{ | ||
Text = "Leading" | ||
}; | ||
} | ||
else | ||
{ | ||
_customTitleBar!.LeadingContent = null; | ||
} | ||
} | ||
|
||
private void ContentCheckBox_CheckedChanged(object sender, CheckedChangedEventArgs e) | ||
{ | ||
if (e.Value) | ||
{ | ||
_customTitleBar!.Content = new SearchBar() | ||
{ | ||
Placeholder = "Search", | ||
MaximumWidthRequest = 300, | ||
HorizontalOptions = LayoutOptions.Fill, | ||
VerticalOptions = LayoutOptions.Center | ||
}; | ||
} | ||
else | ||
{ | ||
_customTitleBar!.Content = null; | ||
} | ||
} | ||
|
||
private void TrailingCheckBox_CheckedChanged(object sender, CheckedChangedEventArgs e) | ||
{ | ||
if (e.Value) | ||
{ | ||
_customTitleBar!.TrailingContent = new Border() | ||
{ | ||
WidthRequest = 32, | ||
HeightRequest = 32, | ||
StrokeShape = new Ellipse() { WidthRequest = 32, HeightRequest = 32 }, | ||
StrokeThickness = 0, | ||
BackgroundColor = Colors.Azure, | ||
Content = new Label() | ||
{ | ||
Text = "User", | ||
TextColor = Colors.Black, | ||
HorizontalOptions = LayoutOptions.Center, | ||
VerticalOptions = LayoutOptions.Center, | ||
FontSize = 10 | ||
} | ||
}; | ||
} | ||
else | ||
{ | ||
_customTitleBar!.TrailingContent = null; | ||
} | ||
} | ||
|
||
private void TallModeCheckBox_CheckedChanged(object sender, CheckedChangedEventArgs e) | ||
{ | ||
if (e.Value) | ||
{ | ||
_customTitleBar!.HeightRequest = 48; | ||
} | ||
else | ||
{ | ||
_customTitleBar!.HeightRequest = 32; | ||
} | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
9.0/UserInterface/Views/TitleBarDemo/TitleBarDemo/MainWindow.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,29 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<Window xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:local="clr-namespace:TitleBarDemo" | ||
x:Class="TitleBarDemo.MainWindow"> | ||
<Window.BindingContext> | ||
<local:MainWindowViewModel /> | ||
</Window.BindingContext> | ||
<Window.Page> | ||
<local:AppShell /> | ||
</Window.Page> | ||
<Window.TitleBar> | ||
<TitleBar x:Name="titleBar" | ||
Title="{Binding Title}" | ||
Subtitle="{Binding Subtitle}" | ||
IsVisible="{Binding ShowTitleBar}" | ||
BackgroundColor="#512BD4" | ||
ForegroundColor="White" | ||
HeightRequest="48"> | ||
<TitleBar.Content> | ||
<SearchBar Placeholder="Search" | ||
PlaceholderColor="White" | ||
MaximumWidthRequest="300" | ||
HorizontalOptions="Fill" | ||
VerticalOptions="Center" /> | ||
</TitleBar.Content> | ||
</TitleBar> | ||
</Window.TitleBar> | ||
</Window> |
10 changes: 10 additions & 0 deletions
10
9.0/UserInterface/Views/TitleBarDemo/TitleBarDemo/MainWindow.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,10 @@ | ||
namespace TitleBarDemo; | ||
|
||
public partial class MainWindow : Window | ||
{ | ||
public MainWindow() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
} |
Oops, something went wrong.