committed by
GitHub
120 changed files with 2874 additions and 1300 deletions
@ -1,16 +0,0 @@ |
|||
<Project> |
|||
<ItemGroup Condition="'$(AndroidApplication)' == 'true'"> |
|||
<!-- WORKAROUND: The packages below are transitively referenced by System.Memory, |
|||
but Xamarin.Android applications need the newest versions directly referenced for the linker. --> |
|||
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="4.6.0" /> |
|||
<PackageReference Include="System.Buffers" Version="4.5.0" /> |
|||
</ItemGroup> |
|||
<Target Name="_RemoveNonExistingResgenFile" BeforeTargets="CoreCompile" Condition="'$(_SdkSetAndroidResgenFile)' == 'true' And '$(AndroidResgenFile)' != '' And !Exists('$(AndroidResgenFile)')"> |
|||
<ItemGroup> |
|||
<Compile Remove="$(AndroidResgenFile)"/> |
|||
</ItemGroup> |
|||
</Target> |
|||
<PropertyGroup> |
|||
<DesignTimeBuild>false</DesignTimeBuild> |
|||
</PropertyGroup> |
|||
</Project> |
|||
@ -1,19 +0,0 @@ |
|||
Any raw assets you want to be deployed with your application can be placed in |
|||
this directory (and child directories) and given a Build Action of "AndroidAsset". |
|||
|
|||
These files will be deployed with your package and will be accessible using Android's |
|||
AssetManager, like this: |
|||
|
|||
public class ReadAsset : Activity |
|||
{ |
|||
protected override void OnCreate (Bundle bundle) |
|||
{ |
|||
base.OnCreate (bundle); |
|||
|
|||
InputStream input = Assets.Open ("my_asset.txt"); |
|||
} |
|||
} |
|||
|
|||
Additionally, some Android functions will automatically load asset files: |
|||
|
|||
Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf"); |
|||
@ -1,165 +1,46 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
<PropertyGroup> |
|||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
|||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
|||
<ProductVersion>8.0.30703</ProductVersion> |
|||
<SchemaVersion>2.0</SchemaVersion> |
|||
<ProjectGuid>{29132311-1848-4FD6-AE0C-4FF841151BD3}</ProjectGuid> |
|||
<ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> |
|||
<OutputType>Library</OutputType> |
|||
<AppDesignerFolder>Properties</AppDesignerFolder> |
|||
<RootNamespace>ControlCatalog.Android</RootNamespace> |
|||
<AssemblyName>ControlCatalog.Android</AssemblyName> |
|||
<FileAlignment>512</FileAlignment> |
|||
<AndroidApplication>true</AndroidApplication> |
|||
<AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile> |
|||
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> |
|||
<AndroidUseLatestPlatformSdk>False</AndroidUseLatestPlatformSdk> |
|||
<TargetFrameworkVersion>v11.0</TargetFrameworkVersion> |
|||
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest> |
|||
<TargetFramework>net6.0-android</TargetFramework> |
|||
<SupportedOSPlatformVersion>21</SupportedOSPlatformVersion> |
|||
<OutputType>Exe</OutputType> |
|||
<Nullable>enable</Nullable> |
|||
<ApplicationId>com.Avalonia.ControlCatalog</ApplicationId> |
|||
<ApplicationVersion>1</ApplicationVersion> |
|||
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion> |
|||
<AndroidPackageFormat>apk</AndroidPackageFormat> |
|||
<MSBuildEnableWorkloadResolver>true</MSBuildEnableWorkloadResolver> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
|||
<DebugSymbols>True</DebugSymbols> |
|||
<DebugType>full</DebugType> |
|||
<Optimize>false</Optimize> |
|||
<OutputPath>bin\Debug\</OutputPath> |
|||
<DefineConstants>DEBUG;TRACE</DefineConstants> |
|||
<ErrorReport>prompt</ErrorReport> |
|||
<WarningLevel>4</WarningLevel> |
|||
<AndroidUseSharedRuntime>True</AndroidUseSharedRuntime> |
|||
<AndroidLinkMode>None</AndroidLinkMode> |
|||
<EmbedAssembliesIntoApk>True</EmbedAssembliesIntoApk> |
|||
<BundleAssemblies>False</BundleAssemblies> |
|||
<AndroidCreatePackagePerAbi>False</AndroidCreatePackagePerAbi> |
|||
<AndroidSupportedAbis>armeabi-v7a;x86;x86_64</AndroidSupportedAbis> |
|||
<Debugger>Xamarin</Debugger> |
|||
<AndroidEnableMultiDex>False</AndroidEnableMultiDex> |
|||
<AotAssemblies>False</AotAssemblies> |
|||
<EnableLLVM>False</EnableLLVM> |
|||
<EnableProguard>False</EnableProguard> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
|||
<DebugType>pdbonly</DebugType> |
|||
<Optimize>true</Optimize> |
|||
<OutputPath>bin\Release\</OutputPath> |
|||
<DefineConstants>TRACE</DefineConstants> |
|||
<ErrorReport>prompt</ErrorReport> |
|||
<WarningLevel>4</WarningLevel> |
|||
<AndroidUseSharedRuntime>False</AndroidUseSharedRuntime> |
|||
<AndroidLinkMode>Full</AndroidLinkMode> |
|||
<EmbedAssembliesIntoApk>True</EmbedAssembliesIntoApk> |
|||
<BundleAssemblies>False</BundleAssemblies> |
|||
<AndroidCreatePackagePerAbi>False</AndroidCreatePackagePerAbi> |
|||
<AndroidSupportedAbis>armeabi-v7a,x86;x86_64</AndroidSupportedAbis> |
|||
<Debugger>Xamarin</Debugger> |
|||
<AotAssemblies>False</AotAssemblies> |
|||
<EnableLLVM>False</EnableLLVM> |
|||
<AndroidEnableMultiDex>False</AndroidEnableMultiDex> |
|||
<EnableProguard>False</EnableProguard> |
|||
<DebugSymbols>False</DebugSymbols> |
|||
</PropertyGroup> |
|||
<ItemGroup> |
|||
<Reference Include="Mono.Android" /> |
|||
<Reference Include="mscorlib" /> |
|||
<Reference Include="System" /> |
|||
<Reference Include="System.Core" /> |
|||
<Reference Include="System.Xml.Linq" /> |
|||
<Reference Include="System.Xml" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<Compile Include="MainActivity.cs" /> |
|||
<Compile Include="Resources\Resource.Designer.cs" /> |
|||
<Compile Include="Properties\AssemblyInfo.cs" /> |
|||
<Compile Include="SplashActivity.cs" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<None Include="Resources\AboutResources.txt" /> |
|||
<None Include="Assets\AboutAssets.txt" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<AndroidResource Include="Resources\drawable\splash_screen.xml" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<AndroidResource Include="Resources\values\colors.xml" /> |
|||
<AndroidResource Include="Resources\values\styles.xml" /> |
|||
<None Remove="Assets\AboutAssets.txt" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<AndroidResource Include="..\..\build\Assets\Icon.png"> |
|||
<Link>Resources\drawable\Icon.png</Link> |
|||
</AndroidResource> |
|||
</ItemGroup> |
|||
|
|||
<PropertyGroup Condition="'$(Configuration)'=='Release' and '$(TF_BUILD)' == ''"> |
|||
<DebugSymbols>True</DebugSymbols> |
|||
<RunAOTCompilation>False</RunAOTCompilation> |
|||
<EnableLLVM>True</EnableLLVM> |
|||
</PropertyGroup> |
|||
|
|||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> |
|||
<EmbedAssembliesIntoApk>False</EmbedAssembliesIntoApk> |
|||
<RunAOTCompilation>False</RunAOTCompilation> |
|||
</PropertyGroup> |
|||
|
|||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'"> |
|||
<EmbedAssembliesIntoApk>True</EmbedAssembliesIntoApk> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<None Include="Properties\AndroidManifest.xml" /> |
|||
<PackageReference Include="Xamarin.AndroidX.AppCompat" Version="1.3.1.3" /> |
|||
<PackageReference Include="Xamarin.AndroidX.Lifecycle.ViewModel" Version="2.3.1.3" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\src\Android\Avalonia.Android\Avalonia.Android.csproj"> |
|||
<Project>{7B92AF71-6287-4693-9DCB-BD5B6E927E23}</Project> |
|||
<Name>Avalonia.Android</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Animation\Avalonia.Animation.csproj"> |
|||
<Project>{d211e587-d8bc-45b9-95a4-f297c8fa5200}</Project> |
|||
<Name>Avalonia.Animation</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Base\Avalonia.Base.csproj"> |
|||
<Project>{b09b78d8-9b26-48b0-9149-d64a2f120f3f}</Project> |
|||
<Name>Avalonia.Base</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Controls\Avalonia.Controls.csproj"> |
|||
<Project>{d2221c82-4a25-4583-9b43-d791e3f6820c}</Project> |
|||
<Name>Avalonia.Controls</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Diagnostics\Avalonia.Diagnostics.csproj"> |
|||
<Project>{7062ae20-5dcc-4442-9645-8195bdece63e}</Project> |
|||
<Name>Avalonia.Diagnostics</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Input\Avalonia.Input.csproj"> |
|||
<Project>{62024b2d-53eb-4638-b26b-85eeaa54866e}</Project> |
|||
<Name>Avalonia.Input</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Interactivity\Avalonia.Interactivity.csproj"> |
|||
<Project>{6b0ed19d-a08b-461c-a9d9-a9ee40b0c06b}</Project> |
|||
<Name>Avalonia.Interactivity</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Layout\Avalonia.Layout.csproj"> |
|||
<Project>{42472427-4774-4c81-8aff-9f27b8e31721}</Project> |
|||
<Name>Avalonia.Layout</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Themes.Fluent\Avalonia.Themes.Fluent.csproj"> |
|||
<Project>{c42d2fc1-a531-4ed4-84b9-89aec7c962fc}</Project> |
|||
<Name>Avalonia.Themes.Fluent</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Visuals\Avalonia.Visuals.csproj"> |
|||
<Project>{eb582467-6abb-43a1-b052-e981ba910e3a}</Project> |
|||
<Name>Avalonia.Visuals</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Styling\Avalonia.Styling.csproj"> |
|||
<Project>{f1baa01a-f176-4c6a-b39d-5b40bb1b148f}</Project> |
|||
<Name>Avalonia.Styling</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Avalonia.Themes.Default\Avalonia.Themes.Default.csproj"> |
|||
<Project>{3e10a5fa-e8da-48b1-ad44-6a5b6cb7750f}</Project> |
|||
<Name>Avalonia.Themes.Default</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Markup\Avalonia.Markup.Xaml\Avalonia.Markup.Xaml.csproj"> |
|||
<Project>{3e53a01a-b331-47f3-b828-4a5717e77a24}</Project> |
|||
<Name>Avalonia.Markup.Xaml</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Markup\Avalonia.Markup\Avalonia.Markup.csproj"> |
|||
<Project>{6417e941-21bc-467b-a771-0de389353ce6}</Project> |
|||
<Name>Avalonia.Markup</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Skia\Avalonia.Skia\Avalonia.Skia.csproj"> |
|||
<Project>{7d2d3083-71dd-4cc9-8907-39a0d86fb322}</Project> |
|||
<Name>Avalonia.Skia</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\ControlCatalog\ControlCatalog.csproj"> |
|||
<Project>{d0a739b9-3c68-4ba6-a328-41606954b6bd}</Project> |
|||
<Name>ControlCatalog</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Android\Avalonia.Android\Avalonia.Android.csproj" /> |
|||
<ProjectReference Include="..\ControlCatalog\ControlCatalog.csproj" /> |
|||
</ItemGroup> |
|||
<Import Project="..\..\build\Rx.props" /> |
|||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" /> |
|||
<Import Project="..\..\build\AndroidWorkarounds.props" /> |
|||
<Import Project="..\..\build\LegacyProject.targets" /> |
|||
</Project> |
|||
|
|||
@ -1,5 +1,4 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="ControlCatalog.Android" android:versionCode="1" android:versionName="1.0" android:installLocation="auto"> |
|||
<uses-sdk android:targetSdkVersion="30" /> |
|||
<application android:label="ControlCatalog.Android"></application> |
|||
</manifest> |
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto"> |
|||
<application android:label="ControlCatalog.Android" android:icon="@drawable/Icon"></application> |
|||
</manifest> |
|||
|
|||
@ -1,30 +0,0 @@ |
|||
using System.Reflection; |
|||
using System.Runtime.CompilerServices; |
|||
using System.Runtime.InteropServices; |
|||
using Android.App; |
|||
|
|||
// General Information about an assembly is controlled through the following
|
|||
// set of attributes. Change these attribute values to modify the information
|
|||
// associated with an assembly.
|
|||
[assembly: AssemblyTitle("ControlCatalog.Android")] |
|||
[assembly: AssemblyDescription("")] |
|||
[assembly: AssemblyConfiguration("")] |
|||
[assembly: AssemblyCompany("")] |
|||
[assembly: AssemblyProduct("ControlCatalog.Android")] |
|||
[assembly: AssemblyCopyright("Copyright © 2016")] |
|||
[assembly: AssemblyTrademark("")] |
|||
[assembly: AssemblyCulture("")] |
|||
[assembly: ComVisible(false)] |
|||
|
|||
// Version information for an assembly consists of the following four values:
|
|||
//
|
|||
// Major Version
|
|||
// Minor Version
|
|||
// Build Number
|
|||
// Revision
|
|||
//
|
|||
// You can specify all the values or you can default the Build and Revision Numbers
|
|||
// by using the '*' as shown below:
|
|||
// [assembly: AssemblyVersion("1.0.*")]
|
|||
[assembly: AssemblyVersion("1.0.0.0")] |
|||
[assembly: AssemblyFileVersion("1.0.0.0")] |
|||
@ -1,101 +0,0 @@ |
|||
#pragma warning disable 1591
|
|||
//------------------------------------------------------------------------------
|
|||
// <auto-generated>
|
|||
// This code was generated by a tool.
|
|||
//
|
|||
// Changes to this file may cause incorrect behavior and will be lost if
|
|||
// the code is regenerated.
|
|||
// </auto-generated>
|
|||
//------------------------------------------------------------------------------
|
|||
|
|||
[assembly: global::Android.Runtime.ResourceDesignerAttribute("ControlCatalog.Android.Resource", IsApplication=true)] |
|||
|
|||
namespace ControlCatalog.Android |
|||
{ |
|||
|
|||
|
|||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "12.1.99.62")] |
|||
public partial class Resource |
|||
{ |
|||
|
|||
static Resource() |
|||
{ |
|||
global::Android.Runtime.ResourceIdManager.UpdateIdValues(); |
|||
} |
|||
|
|||
public static void UpdateIdValues() |
|||
{ |
|||
} |
|||
|
|||
public partial class Attribute |
|||
{ |
|||
|
|||
static Attribute() |
|||
{ |
|||
global::Android.Runtime.ResourceIdManager.UpdateIdValues(); |
|||
} |
|||
|
|||
private Attribute() |
|||
{ |
|||
} |
|||
} |
|||
|
|||
public partial class Color |
|||
{ |
|||
|
|||
// aapt resource value: 0x7F010000
|
|||
public const int splash_background = 2130771968; |
|||
|
|||
static Color() |
|||
{ |
|||
global::Android.Runtime.ResourceIdManager.UpdateIdValues(); |
|||
} |
|||
|
|||
private Color() |
|||
{ |
|||
} |
|||
} |
|||
|
|||
public partial class Drawable |
|||
{ |
|||
|
|||
// aapt resource value: 0x7F020000
|
|||
public const int Icon = 2130837504; |
|||
|
|||
// aapt resource value: 0x7F020001
|
|||
public const int splash_screen = 2130837505; |
|||
|
|||
static Drawable() |
|||
{ |
|||
global::Android.Runtime.ResourceIdManager.UpdateIdValues(); |
|||
} |
|||
|
|||
private Drawable() |
|||
{ |
|||
} |
|||
} |
|||
|
|||
public partial class Style |
|||
{ |
|||
|
|||
// aapt resource value: 0x7F030000
|
|||
public const int MyTheme = 2130903040; |
|||
|
|||
// aapt resource value: 0x7F030001
|
|||
public const int MyTheme_NoActionBar = 2130903041; |
|||
|
|||
// aapt resource value: 0x7F030002
|
|||
public const int MyTheme_Splash = 2130903042; |
|||
|
|||
static Style() |
|||
{ |
|||
global::Android.Runtime.ResourceIdManager.UpdateIdValues(); |
|||
} |
|||
|
|||
private Style() |
|||
{ |
|||
} |
|||
} |
|||
} |
|||
} |
|||
#pragma warning restore 1591
|
|||
@ -1,45 +0,0 @@ |
|||
<UserControl xmlns="https://github.com/avaloniaui" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
x:Class="ControlCatalog.Pages.ButtonPage"> |
|||
<StackPanel Orientation="Vertical" Spacing="4"> |
|||
<TextBlock Classes="h2">A button control</TextBlock> |
|||
|
|||
<StackPanel Orientation="Horizontal" |
|||
Margin="0,16,0,0" |
|||
HorizontalAlignment="Center" |
|||
Spacing="16"> |
|||
<StackPanel Orientation="Vertical" Spacing="8" Width="200"> |
|||
<Button>Standard _XAML Button</Button> |
|||
<Button Foreground="White">Foreground</Button> |
|||
<Button Background="{DynamicResource SystemAccentColor}">Background</Button> |
|||
<Button IsEnabled="False">Disabled</Button> |
|||
<Button Content="Re-themed"> |
|||
<Button.Styles> |
|||
<Style> |
|||
<Style.Resources> |
|||
<SolidColorBrush x:Key="ThemeBorderMidBrush">Red</SolidColorBrush> |
|||
<SolidColorBrush x:Key="ThemeControlHighBrush">DarkRed</SolidColorBrush> |
|||
<SolidColorBrush x:Key="ButtonBorderBrush">Red</SolidColorBrush> |
|||
<SolidColorBrush x:Key="ButtonBackground">DarkRed</SolidColorBrush> |
|||
<SolidColorBrush x:Key="ButtonBackgroundPointerOver">Red</SolidColorBrush> |
|||
<SolidColorBrush x:Key="ButtonBackgroundPressed">OrangeRed</SolidColorBrush> |
|||
</Style.Resources> |
|||
</Style> |
|||
</Button.Styles> |
|||
</Button> |
|||
<RepeatButton Name="RepeatButton"> |
|||
<TextBlock Name="RepeatButtonTextBlock" Text="Repeat Button: 0" /> |
|||
</RepeatButton> |
|||
<ToggleButton Content="Toggle Button"/> |
|||
</StackPanel> |
|||
|
|||
<StackPanel Orientation="Vertical" Spacing="8" Width="150"> |
|||
<Button BorderThickness="0">No Border</Button> |
|||
<Button BorderBrush="{DynamicResource SystemAccentColor}">Border Color</Button> |
|||
<Button BorderBrush="{DynamicResource SystemAccentColor}" BorderThickness="4">Thick Border</Button> |
|||
<Button BorderBrush="{DynamicResource SystemAccentColor}" BorderThickness="4" IsEnabled="False">Disabled</Button> |
|||
<Button BorderBrush="{DynamicResource SystemAccentColor}" KeyboardNavigation.IsTabStop="False">IsTabStop=False</Button> |
|||
</StackPanel> |
|||
</StackPanel> |
|||
</StackPanel> |
|||
</UserControl> |
|||
@ -0,0 +1,224 @@ |
|||
<UserControl xmlns="https://github.com/avaloniaui" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
x:Class="ControlCatalog.Pages.ButtonsPage"> |
|||
|
|||
<UserControl.Resources> |
|||
|
|||
<MenuFlyout x:Key="SharedMenuFlyout" |
|||
Placement="Bottom"> |
|||
<MenuItem Header="Item 1"> |
|||
<MenuItem Header="Subitem 1" /> |
|||
<MenuItem Header="Subitem 2" /> |
|||
<MenuItem Header="Subitem 3" /> |
|||
</MenuItem> |
|||
<MenuItem Header="Item 2" |
|||
InputGesture="Ctrl+A" /> |
|||
<MenuItem Header="Item 3" /> |
|||
</MenuFlyout> |
|||
|
|||
</UserControl.Resources> |
|||
|
|||
<UserControl.Styles > |
|||
|
|||
<Style Selector="Border.header-border"> |
|||
<Setter Property="Background"> |
|||
<Setter.Value> |
|||
<SolidColorBrush Color="Gray" Opacity="0.5" /> |
|||
</Setter.Value> |
|||
</Setter> |
|||
<Setter Property="BorderBrush" Value="Gray" /> |
|||
<Setter Property="BorderThickness" Value="0.5" /> |
|||
<Setter Property="CornerRadius" Value="5,5,0,0" /> |
|||
<Setter Property="MaxWidth" Value="450" /> |
|||
<Setter Property="Padding" Value="10" /> |
|||
</Style> |
|||
|
|||
<Style Selector="TextBlock.header"> |
|||
<Setter Property="FontSize" Value="18" /> |
|||
<Setter Property="FontWeight" Value="Bold" /> |
|||
</Style> |
|||
|
|||
<Style Selector="Border.thin"> |
|||
<Setter Property="BorderBrush" Value="Gray" /> |
|||
<Setter Property="BorderThickness" Value="0.5" /> |
|||
<Setter Property="CornerRadius" Value="0,0,5,5" /> |
|||
<Setter Property="Margin" Value="0,0,0,15" /> |
|||
</Style> |
|||
|
|||
</UserControl.Styles> |
|||
|
|||
<!-- Styles and overall page design based on AcrylicPage --> |
|||
|
|||
<StackPanel Orientation="Vertical" |
|||
Width="450"> |
|||
|
|||
<!-- Button --> |
|||
<Border Classes="header-border"> |
|||
<StackPanel Orientation="Vertical" |
|||
Spacing="4"> |
|||
<TextBlock Text="Button" Classes="header" /> |
|||
<TextBlock TextWrapping="Wrap">A standard button control</TextBlock> |
|||
</StackPanel> |
|||
</Border> |
|||
|
|||
<Border Classes="thin" |
|||
Padding="15"> |
|||
<StackPanel Orientation="Horizontal" |
|||
HorizontalAlignment="Center" |
|||
Spacing="10"> |
|||
<StackPanel Orientation="Vertical" |
|||
Spacing="8" |
|||
Width="200"> |
|||
<Button>Standard _XAML Button</Button> |
|||
<Button Foreground="White">Foreground</Button> |
|||
<Button Background="{DynamicResource SystemAccentColor}">Background</Button> |
|||
<Button IsEnabled="False">Disabled</Button> |
|||
<Button Content="Re-themed"> |
|||
<Button.Styles> |
|||
<Style> |
|||
<Style.Resources> |
|||
<SolidColorBrush x:Key="ThemeBorderMidBrush">Red</SolidColorBrush> |
|||
<SolidColorBrush x:Key="ThemeControlHighBrush">DarkRed</SolidColorBrush> |
|||
<SolidColorBrush x:Key="ButtonBorderBrush">Red</SolidColorBrush> |
|||
<SolidColorBrush x:Key="ButtonBackground">DarkRed</SolidColorBrush> |
|||
<SolidColorBrush x:Key="ButtonBackgroundPointerOver">Red</SolidColorBrush> |
|||
<SolidColorBrush x:Key="ButtonBackgroundPressed">OrangeRed</SolidColorBrush> |
|||
<SolidColorBrush x:Key="ButtonForeground">White</SolidColorBrush> |
|||
<SolidColorBrush x:Key="ButtonForegroundPointerOver">Black</SolidColorBrush> |
|||
<SolidColorBrush x:Key="ButtonForegroundPressed">Black</SolidColorBrush> |
|||
</Style.Resources> |
|||
</Style> |
|||
</Button.Styles> |
|||
</Button> |
|||
</StackPanel> |
|||
|
|||
<StackPanel Orientation="Vertical" |
|||
Spacing="8" |
|||
Width="200"> |
|||
<Button BorderThickness="0">No Border</Button> |
|||
<Button BorderBrush="{DynamicResource SystemAccentColor}">Border Color</Button> |
|||
<Button BorderBrush="{DynamicResource SystemAccentColor}" |
|||
BorderThickness="4">Thick Border</Button> |
|||
<Button BorderBrush="{DynamicResource SystemAccentColor}" |
|||
BorderThickness="4" |
|||
IsEnabled="False">Disabled</Button> |
|||
<Button BorderBrush="{DynamicResource SystemAccentColor}" |
|||
KeyboardNavigation.IsTabStop="False">IsTabStop=False</Button> |
|||
</StackPanel> |
|||
</StackPanel> |
|||
</Border> |
|||
|
|||
<!-- ToggleButton --> |
|||
<Border Classes="header-border"> |
|||
<StackPanel Orientation="Vertical" |
|||
Spacing="4"> |
|||
<TextBlock Text="ToggleButton" |
|||
Classes="header" /> |
|||
<TextBlock TextWrapping="Wrap">A button control with multiple states: checked, unchecked or indeterminate.</TextBlock> |
|||
</StackPanel> |
|||
</Border> |
|||
|
|||
<Border Classes="thin" |
|||
Padding="15"> |
|||
<StackPanel Orientation="Vertical" |
|||
Spacing="8"> |
|||
<ToggleButton Content="Toggle Button" /> |
|||
</StackPanel> |
|||
</Border> |
|||
|
|||
<!-- RepeatButton --> |
|||
<Border Classes="header-border"> |
|||
<StackPanel Orientation="Vertical" |
|||
Spacing="4"> |
|||
<TextBlock Text="RepeatButton" |
|||
Classes="header" /> |
|||
<TextBlock TextWrapping="Wrap">A button control that raises its Click event repeatedly when it is pressed and held.</TextBlock> |
|||
</StackPanel> |
|||
</Border> |
|||
|
|||
<Border Classes="thin" |
|||
Padding="15"> |
|||
<StackPanel Orientation="Vertical" |
|||
Spacing="8"> |
|||
<RepeatButton Name="RepeatButton"> |
|||
<TextBlock Name="RepeatButtonTextBlock" |
|||
Text="Repeat Button: 0" /> |
|||
</RepeatButton> |
|||
</StackPanel> |
|||
</Border> |
|||
|
|||
<!-- SplitButton --> |
|||
<Border Classes="header-border"> |
|||
<StackPanel Orientation="Vertical" |
|||
Spacing="4"> |
|||
<TextBlock Text="SplitButton" |
|||
Classes="header" /> |
|||
<TextBlock TextWrapping="Wrap">A button with primary and secondary parts that can each be pressed separately. The primary part behaves like a Button and the secondary part opens a flyout.</TextBlock> |
|||
</StackPanel> |
|||
</Border> |
|||
|
|||
<Border Classes="thin" |
|||
Padding="15"> |
|||
<StackPanel Orientation="Vertical" |
|||
Spacing="8"> |
|||
<SplitButton Flyout="{StaticResource SharedMenuFlyout}"> |
|||
<TextBlock Text="Content" /> |
|||
</SplitButton> |
|||
<SplitButton IsEnabled="False" |
|||
Flyout="{StaticResource SharedMenuFlyout}"> |
|||
<TextBlock Text="Disabled" /> |
|||
</SplitButton> |
|||
<SplitButton Flyout="{StaticResource SharedMenuFlyout}" |
|||
Content="Re-themed"> |
|||
<SplitButton.Styles> |
|||
<Style> |
|||
<Style.Resources> |
|||
<x:Double x:Key="SplitButtonSeparatorWidth">1.5</x:Double> |
|||
<Thickness x:Key="SplitButtonBorderThemeThickness">2</Thickness> |
|||
<SolidColorBrush x:Key="SplitButtonBorderBrush">Red</SolidColorBrush> |
|||
<SolidColorBrush x:Key="SplitButtonBorderBrushPointerOver">Red</SolidColorBrush> |
|||
<SolidColorBrush x:Key="SplitButtonBorderBrushPressed">Red</SolidColorBrush> |
|||
<SolidColorBrush x:Key="SplitButtonBackground">DarkRed</SolidColorBrush> |
|||
<SolidColorBrush x:Key="SplitButtonBackgroundPointerOver">Red</SolidColorBrush> |
|||
<SolidColorBrush x:Key="SplitButtonBackgroundPressed">OrangeRed</SolidColorBrush> |
|||
<SolidColorBrush x:Key="SplitButtonForeground">White</SolidColorBrush> |
|||
<SolidColorBrush x:Key="SplitButtonForegroundPointerOver">Black</SolidColorBrush> |
|||
<SolidColorBrush x:Key="SplitButtonForegroundPressed">Black</SolidColorBrush> |
|||
</Style.Resources> |
|||
</Style> |
|||
</SplitButton.Styles> |
|||
</SplitButton> |
|||
</StackPanel> |
|||
</Border> |
|||
|
|||
<!-- ToggleSplitButton --> |
|||
<Border Classes="header-border"> |
|||
<StackPanel Orientation="Vertical" |
|||
Spacing="4"> |
|||
<TextBlock Text="ToggleSplitButton" |
|||
Classes="header" /> |
|||
<TextBlock TextWrapping="Wrap">A button with primary and secondary parts that can each be pressed separately. The primary part behaves like a ToggleButton with two states and the secondary part opens a flyout.</TextBlock> |
|||
</StackPanel> |
|||
</Border> |
|||
|
|||
<Border Classes="thin" |
|||
Padding="15"> |
|||
<StackPanel Orientation="Vertical" |
|||
Spacing="8"> |
|||
<ToggleSplitButton Flyout="{StaticResource SharedMenuFlyout}"> |
|||
<TextBlock Text="Content" /> |
|||
</ToggleSplitButton> |
|||
<ToggleSplitButton IsChecked="True" |
|||
Flyout="{StaticResource SharedMenuFlyout}"> |
|||
<TextBlock Text="Content" /> |
|||
</ToggleSplitButton> |
|||
<ToggleSplitButton IsChecked="True" |
|||
IsEnabled="False" |
|||
Flyout="{StaticResource SharedMenuFlyout}"> |
|||
<TextBlock Text="Disabled" /> |
|||
</ToggleSplitButton> |
|||
</StackPanel> |
|||
</Border> |
|||
|
|||
</StackPanel> |
|||
</UserControl> |
|||
@ -0,0 +1,23 @@ |
|||
<UserControl x:Class="ControlCatalog.Pages.ClipboardPage" |
|||
xmlns="https://github.com/avaloniaui" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> |
|||
<StackPanel Orientation="Vertical" Spacing="4"> |
|||
<TextBlock Classes="h2">Example of ClipboardPage capabilities</TextBlock> |
|||
|
|||
<Button Click="CopyText" Content="Copy text to clipboard" /> |
|||
<Button Click="PasteText" Content="Paste text from clipboard" /> |
|||
<Button Click="CopyTextDataObject" Content="Copy text to clipboard (data object)" /> |
|||
<Button Click="PasteTextDataObject" Content="Paste text from clipboard (data object)" /> |
|||
|
|||
<Button Click="CopyFilesDataObject" Content="Copy files to clipboard (data object)" /> |
|||
<Button Click="PasteFilesDataObject" Content="Paste files from clipboard (data object)" /> |
|||
|
|||
<Button Click="GetFormats" Content="Get clipboard formats" /> |
|||
<Button Click="Clear" Content="Clear clipboard" /> |
|||
|
|||
<TextBox x:Name="ClipboardContent" |
|||
MinHeight="100" |
|||
AcceptsReturn="True" |
|||
Watermark="Text to copy of file names per line" /> |
|||
</StackPanel> |
|||
</UserControl> |
|||
@ -0,0 +1,77 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
|
|||
using Avalonia; |
|||
using Avalonia.Controls; |
|||
using Avalonia.Input; |
|||
using Avalonia.Interactivity; |
|||
using Avalonia.Markup.Xaml; |
|||
|
|||
namespace ControlCatalog.Pages |
|||
{ |
|||
public partial class ClipboardPage : UserControl |
|||
{ |
|||
public ClipboardPage() |
|||
{ |
|||
InitializeComponent(); |
|||
} |
|||
|
|||
private TextBox ClipboardContent => this.Get<TextBox>("ClipboardContent"); |
|||
|
|||
private void InitializeComponent() |
|||
{ |
|||
AvaloniaXamlLoader.Load(this); |
|||
} |
|||
|
|||
private async void CopyText(object sender, RoutedEventArgs args) |
|||
{ |
|||
await Application.Current.Clipboard.SetTextAsync(ClipboardContent.Text); |
|||
} |
|||
|
|||
private async void PasteText(object sender, RoutedEventArgs args) |
|||
{ |
|||
ClipboardContent.Text = await Application.Current.Clipboard.GetTextAsync(); |
|||
} |
|||
|
|||
private async void CopyTextDataObject(object sender, RoutedEventArgs args) |
|||
{ |
|||
var dataObject = new DataObject(); |
|||
dataObject.Set(DataFormats.Text, ClipboardContent.Text ?? string.Empty); |
|||
await Application.Current.Clipboard.SetDataObjectAsync(dataObject); |
|||
} |
|||
|
|||
private async void PasteTextDataObject(object sender, RoutedEventArgs args) |
|||
{ |
|||
ClipboardContent.Text = await Application.Current.Clipboard.GetDataAsync(DataFormats.Text) as string ?? string.Empty; |
|||
} |
|||
|
|||
private async void CopyFilesDataObject(object sender, RoutedEventArgs args) |
|||
{ |
|||
var files = ClipboardContent.Text.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); |
|||
if (files.Length == 0) |
|||
{ |
|||
return; |
|||
} |
|||
var dataObject = new DataObject(); |
|||
dataObject.Set(DataFormats.FileNames, files); |
|||
await Application.Current.Clipboard.SetDataObjectAsync(dataObject); |
|||
} |
|||
|
|||
private async void PasteFilesDataObject(object sender, RoutedEventArgs args) |
|||
{ |
|||
var fiels = await Application.Current.Clipboard.GetDataAsync(DataFormats.FileNames) as IEnumerable<string>; |
|||
ClipboardContent.Text = fiels != null ? string.Join(Environment.NewLine, fiels) : string.Empty; |
|||
} |
|||
|
|||
private async void GetFormats(object sender, RoutedEventArgs args) |
|||
{ |
|||
var formats = await Application.Current.Clipboard.GetFormatsAsync(); |
|||
ClipboardContent.Text = string.Join(Environment.NewLine, formats); |
|||
} |
|||
|
|||
private async void Clear(object sender, RoutedEventArgs args) |
|||
{ |
|||
await Application.Current.Clipboard.ClearAsync(); |
|||
} |
|||
} |
|||
} |
|||
@ -1,14 +0,0 @@ |
|||
using Avalonia.Controls; |
|||
using Avalonia.PlatformSupport; |
|||
|
|||
namespace Avalonia |
|||
{ |
|||
public sealed class AppBuilder : AppBuilderBase<AppBuilder> |
|||
{ |
|||
public AppBuilder() : base(new StandardRuntimePlatform(), |
|||
builder => StandardRuntimePlatformServices.Register(builder.Instance?.GetType()?.Assembly)) |
|||
{ |
|||
|
|||
} |
|||
} |
|||
} |
|||
@ -1,15 +1,18 @@ |
|||
<Project Sdk="MSBuild.Sdk.Extras"> |
|||
<Project Sdk="Xamarin.Legacy.Sdk"> |
|||
<PropertyGroup> |
|||
<TargetFramework>monoandroid11.0</TargetFramework> |
|||
<TargetFrameworks>net6.0-android;monoandroid11.0</TargetFrameworks> |
|||
<SupportedOSPlatformVersion>21</SupportedOSPlatformVersion> |
|||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> |
|||
<MSBuildEnableWorkloadResolver>true</MSBuildEnableWorkloadResolver> |
|||
<DebugType>portable</DebugType> |
|||
</PropertyGroup> |
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\..\packages\Avalonia\Avalonia.csproj" /> |
|||
<ProjectReference Include="..\..\Avalonia.PlatformSupport\Avalonia.PlatformSupport.csproj"> |
|||
<SetTargetFramework>TargetFramework=netstandard2.0</SetTargetFramework> |
|||
</ProjectReference> |
|||
<PackageReference Include="Xamarin.AndroidX.AppCompat" Version="1.3.1.3" /> |
|||
<PackageReference Include="Xamarin.AndroidX.Lifecycle.ViewModel" Version="2.3.1.3" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\Avalonia.Base\Avalonia.Base.csproj" /> |
|||
<ProjectReference Include="..\..\Skia\Avalonia.Skia\Avalonia.Skia.csproj" /> |
|||
</ItemGroup> |
|||
<Import Project="..\..\..\build\Rx.props" /> |
|||
<Import Project="..\..\..\build\AndroidWorkarounds.props" /> |
|||
</Project> |
|||
|
|||
@ -1,35 +1,55 @@ |
|||
using Android.App; |
|||
using Android.OS; |
|||
using Android.Views; |
|||
using Android.Content.PM; |
|||
using AndroidX.AppCompat.App; |
|||
using Android.Content.Res; |
|||
using AndroidX.Lifecycle; |
|||
|
|||
namespace Avalonia.Android |
|||
{ |
|||
public abstract class AvaloniaActivity : Activity |
|||
public abstract class AvaloniaActivity : AppCompatActivity |
|||
{ |
|||
internal AvaloniaView View; |
|||
object _content; |
|||
|
|||
internal AvaloniaViewModel _viewModel; |
|||
protected override void OnCreate(Bundle savedInstanceState) |
|||
{ |
|||
View = new AvaloniaView(this); |
|||
if (_content != null) |
|||
View.Content = _content; |
|||
SetContentView(View); |
|||
|
|||
_viewModel = new ViewModelProvider(this).Get(Java.Lang.Class.FromType(typeof(AvaloniaViewModel))) as AvaloniaViewModel; |
|||
|
|||
if (_viewModel.Content != null) |
|||
{ |
|||
View.Content = _viewModel.Content; |
|||
} |
|||
|
|||
base.OnCreate(savedInstanceState); |
|||
} |
|||
|
|||
public object Content |
|||
{ |
|||
get |
|||
{ |
|||
return _content; |
|||
return _viewModel.Content; |
|||
} |
|||
set |
|||
{ |
|||
_content = value; |
|||
_viewModel.Content = value; |
|||
if (View != null) |
|||
View.Content = value; |
|||
} |
|||
} |
|||
|
|||
public override void OnConfigurationChanged(Configuration newConfig) |
|||
{ |
|||
base.OnConfigurationChanged(newConfig); |
|||
} |
|||
|
|||
protected override void OnDestroy() |
|||
{ |
|||
View.Content = null; |
|||
|
|||
base.OnDestroy(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,11 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
|
|||
namespace Avalonia.Android |
|||
{ |
|||
internal class AvaloniaViewModel : AndroidX.Lifecycle.ViewModel |
|||
{ |
|||
public object Content { get; set; } |
|||
} |
|||
} |
|||
@ -1,50 +0,0 @@ |
|||
Images, layout descriptions, binary blobs and string dictionaries can be included |
|||
in your application as resource files. Various Android APIs are designed to |
|||
operate on the resource IDs instead of dealing with images, strings or binary blobs |
|||
directly. |
|||
|
|||
For example, a sample Android app that contains a user interface layout (main.xml), |
|||
an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png) |
|||
would keep its resources in the "Resources" directory of the application: |
|||
|
|||
Resources/ |
|||
drawable-hdpi/ |
|||
icon.png |
|||
|
|||
drawable-ldpi/ |
|||
icon.png |
|||
|
|||
drawable-mdpi/ |
|||
icon.png |
|||
|
|||
layout/ |
|||
main.xml |
|||
|
|||
values/ |
|||
strings.xml |
|||
|
|||
In order to get the build system to recognize Android resources, set the build action to |
|||
"AndroidResource". The native Android APIs do not operate directly with filenames, but |
|||
instead operate on resource IDs. When you compile an Android application that uses resources, |
|||
the build system will package the resources for distribution and generate a class called |
|||
"Resource" that contains the tokens for each one of the resources included. For example, |
|||
for the above Resources layout, this is what the Resource class would expose: |
|||
|
|||
public class Resource { |
|||
public class drawable { |
|||
public const int icon = 0x123; |
|||
} |
|||
|
|||
public class layout { |
|||
public const int main = 0x456; |
|||
} |
|||
|
|||
public class strings { |
|||
public const int first_string = 0xabc; |
|||
public const int second_string = 0xbcd; |
|||
} |
|||
} |
|||
|
|||
You would then use R.drawable.icon to reference the drawable/icon.png file, or Resource.layout.main |
|||
to reference the layout/main.xml file, or Resource.strings.first_string to reference the first |
|||
string in the dictionary file values/strings.xml. |
|||
@ -1,6 +0,0 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
|
|||
<resources> |
|||
<string name="Hello">Hello World, Click Me!</string> |
|||
<string name="ApplicationName">$projectname$</string> |
|||
</resources> |
|||
@ -1,19 +0,0 @@ |
|||
Any raw assets you want to be deployed with your application can be placed in |
|||
this directory (and child directories) and given a Build Action of "AndroidAsset". |
|||
|
|||
These files will be deployed with you package and will be accessible using Android's |
|||
AssetManager, like this: |
|||
|
|||
public class ReadAsset : Activity |
|||
{ |
|||
protected override void OnCreate (Bundle bundle) |
|||
{ |
|||
base.OnCreate (bundle); |
|||
|
|||
InputStream input = Assets.Open ("my_asset.txt"); |
|||
} |
|||
} |
|||
|
|||
Additionally, some Android functions will automatically load asset files: |
|||
|
|||
Typeface tf = Typeface.CreateFromAsset (Context.Assets, "fonts/samplefont.ttf"); |
|||
@ -1,153 +1,37 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
<PropertyGroup> |
|||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
|||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
|||
<ProductVersion>8.0.30703</ProductVersion> |
|||
<SchemaVersion>2.0</SchemaVersion> |
|||
<ProjectGuid>{FF69B927-C545-49AE-8E16-3D14D621AA12}</ProjectGuid> |
|||
<ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> |
|||
<OutputType>Library</OutputType> |
|||
<AppDesignerFolder>Properties</AppDesignerFolder> |
|||
<RootNamespace>Avalonia.AndroidTestApplication</RootNamespace> |
|||
<AssemblyName>Avalonia.AndroidTestApplication</AssemblyName> |
|||
<FileAlignment>512</FileAlignment> |
|||
<AndroidApplication>true</AndroidApplication> |
|||
<AndroidResgenFile>Resources\Resource.Designer.cs</AndroidResgenFile> |
|||
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> |
|||
<AndroidUseLatestPlatformSdk>False</AndroidUseLatestPlatformSdk> |
|||
<TargetFrameworkVersion>v11.0</TargetFrameworkVersion> |
|||
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest> |
|||
<TargetFramework>net6.0-android</TargetFramework> |
|||
<SupportedOSPlatformVersion>21</SupportedOSPlatformVersion> |
|||
<OutputType>Exe</OutputType> |
|||
<Nullable>enable</Nullable> |
|||
<ApplicationId>com.Avalonia.AndroidTestApplication</ApplicationId> |
|||
<ApplicationVersion>1</ApplicationVersion> |
|||
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion> |
|||
<AndroidPackageFormat>apk</AndroidPackageFormat> |
|||
<MSBuildEnableWorkloadResolver>true</MSBuildEnableWorkloadResolver> |
|||
<DebugType>portable</DebugType> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
|||
|
|||
<PropertyGroup Condition="'$(Configuration)'=='Release' and '$(TF_BUILD)' == ''"> |
|||
<DebugSymbols>True</DebugSymbols> |
|||
<DebugType>full</DebugType> |
|||
<Optimize>false</Optimize> |
|||
<OutputPath>bin\Debug\</OutputPath> |
|||
<DefineConstants>DEBUG;TRACE</DefineConstants> |
|||
<ErrorReport>prompt</ErrorReport> |
|||
<WarningLevel>4</WarningLevel> |
|||
<AndroidUseSharedRuntime>True</AndroidUseSharedRuntime> |
|||
<AndroidLinkMode>None</AndroidLinkMode> |
|||
<EmbedAssembliesIntoApk>True</EmbedAssembliesIntoApk> |
|||
<BundleAssemblies>False</BundleAssemblies> |
|||
<AndroidCreatePackagePerAbi>False</AndroidCreatePackagePerAbi> |
|||
<AndroidSupportedAbis>armeabi-v7a;x86</AndroidSupportedAbis> |
|||
<Debugger>Xamarin</Debugger> |
|||
<AndroidEnableMultiDex>False</AndroidEnableMultiDex> |
|||
<DevInstrumentationEnabled>True</DevInstrumentationEnabled> |
|||
<AotAssemblies>False</AotAssemblies> |
|||
<EnableLLVM>False</EnableLLVM> |
|||
<EnableProguard>False</EnableProguard> |
|||
<RunAOTCompilation>True</RunAOTCompilation> |
|||
<EnableLLVM>True</EnableLLVM> |
|||
<!--<AndroidEnableProfiledAot>True</AndroidEnableProfiledAot>--> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
|||
<DebugType>pdbonly</DebugType> |
|||
<Optimize>true</Optimize> |
|||
<OutputPath>bin\Release\</OutputPath> |
|||
<DefineConstants>TRACE</DefineConstants> |
|||
<ErrorReport>prompt</ErrorReport> |
|||
<WarningLevel>4</WarningLevel> |
|||
<AndroidUseSharedRuntime>False</AndroidUseSharedRuntime> |
|||
<AndroidLinkMode>Full</AndroidLinkMode> |
|||
<EmbedAssembliesIntoApk>True</EmbedAssembliesIntoApk> |
|||
<BundleAssemblies>False</BundleAssemblies> |
|||
<AndroidCreatePackagePerAbi>False</AndroidCreatePackagePerAbi> |
|||
<AndroidSupportedAbis>armeabi-v7a,x86</AndroidSupportedAbis> |
|||
<Debugger>Xamarin</Debugger> |
|||
<AotAssemblies>False</AotAssemblies> |
|||
<EnableLLVM>False</EnableLLVM> |
|||
<AndroidEnableMultiDex>False</AndroidEnableMultiDex> |
|||
<EnableProguard>False</EnableProguard> |
|||
<DevInstrumentationEnabled>False</DevInstrumentationEnabled> |
|||
<DebugSymbols>False</DebugSymbols> |
|||
</PropertyGroup> |
|||
<ItemGroup> |
|||
<Reference Include="Mono.Android" /> |
|||
<Reference Include="mscorlib" /> |
|||
<Reference Include="System" /> |
|||
<Reference Include="System.Core" /> |
|||
<Reference Include="System.Xml.Linq" /> |
|||
<Reference Include="System.Xml" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<Compile Include="MainActivity.cs" /> |
|||
<Compile Include="Resources\Resource.Designer.cs" /> |
|||
<Compile Include="Properties\AssemblyInfo.cs" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<None Include="app.config" /> |
|||
<None Include="Resources\AboutResources.txt" /> |
|||
<None Include="Assets\AboutAssets.txt" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<AndroidResource Include="Resources\values\Strings.xml"> |
|||
<SubType>Designer</SubType> |
|||
</AndroidResource> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<AndroidResource Include="Resources\drawable\Icon.png" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<None Include="Properties\AndroidManifest.xml" /> |
|||
<None Remove="Assets\AboutAssets.txt" /> |
|||
</ItemGroup> |
|||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> |
|||
<BundleAssemblies>True</BundleAssemblies> |
|||
</PropertyGroup> |
|||
|
|||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'"> |
|||
<BundleAssemblies>True</BundleAssemblies> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\..\src\Android\Avalonia.Android\Avalonia.Android.csproj"> |
|||
<Project>{7b92af71-6287-4693-9dcb-bd5b6e927e23}</Project> |
|||
<Name>Avalonia.Android</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\..\src\Markup\Avalonia.Markup.Xaml\Avalonia.Markup.Xaml.csproj"> |
|||
<Project>{3e53a01a-b331-47f3-b828-4a5717e77a24}</Project> |
|||
<Name>Avalonia.Markup.Xaml</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\..\src\Avalonia.Animation\Avalonia.Animation.csproj"> |
|||
<Project>{d211e587-d8bc-45b9-95a4-f297c8fa5200}</Project> |
|||
<Name>Avalonia.Animation</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\..\src\Avalonia.Base\Avalonia.Base.csproj"> |
|||
<Project>{b09b78d8-9b26-48b0-9149-d64a2f120f3f}</Project> |
|||
<Name>Avalonia.Base</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\..\src\Avalonia.Controls\Avalonia.Controls.csproj"> |
|||
<Project>{d2221c82-4a25-4583-9b43-d791e3f6820c}</Project> |
|||
<Name>Avalonia.Controls</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\..\src\Avalonia.Diagnostics\Avalonia.Diagnostics.csproj"> |
|||
<Project>{7062ae20-5dcc-4442-9645-8195bdece63e}</Project> |
|||
<Name>Avalonia.Diagnostics</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\..\src\Avalonia.Input\Avalonia.Input.csproj"> |
|||
<Project>{62024b2d-53eb-4638-b26b-85eeaa54866e}</Project> |
|||
<Name>Avalonia.Input</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\..\src\Avalonia.Interactivity\Avalonia.Interactivity.csproj"> |
|||
<Project>{6b0ed19d-a08b-461c-a9d9-a9ee40b0c06b}</Project> |
|||
<Name>Avalonia.Interactivity</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\..\src\Avalonia.Layout\Avalonia.Layout.csproj"> |
|||
<Project>{42472427-4774-4c81-8aff-9f27b8e31721}</Project> |
|||
<Name>Avalonia.Layout</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\Avalonia.Visuals\Avalonia.Visuals.csproj"> |
|||
<Project>{eb582467-6abb-43a1-b052-e981ba910e3a}</Project> |
|||
<Name>Avalonia.Visuals</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\..\src\Avalonia.Styling\Avalonia.Styling.csproj"> |
|||
<Project>{f1baa01a-f176-4c6a-b39d-5b40bb1b148f}</Project> |
|||
<Name>Avalonia.Styling</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\..\src\Avalonia.Themes.Default\Avalonia.Themes.Default.csproj"> |
|||
<Project>{3e10a5fa-e8da-48b1-ad44-6a5b6cb7750f}</Project> |
|||
<Name>Avalonia.Themes.Default</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\Skia\Avalonia.Skia\Avalonia.Skia.csproj"> |
|||
<Project>{7d2d3083-71dd-4cc9-8907-39a0d86fb322}</Project> |
|||
<Name>Avalonia.Skia</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\..\packages\Avalonia\Avalonia.csproj" /> |
|||
<ProjectReference Include="..\Avalonia.Android\Avalonia.Android.csproj" /> |
|||
</ItemGroup> |
|||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" /> |
|||
<Import Project="..\..\..\build\Base.props" /> |
|||
<Import Project="..\..\..\build\Rx.props" /> |
|||
<Import Project="..\..\..\build\System.Memory.props" /> |
|||
<Import Project="..\..\..\build\AndroidWorkarounds.props" /> |
|||
<Import Project="..\..\..\build\LegacyProject.targets" /> |
|||
</Project> |
|||
|
|||
@ -1,6 +1,4 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="Avalonia.AndroidTestApplication" android:versionCode="1" android:versionName="1.0" android:installLocation="auto"> |
|||
<uses-sdk android:targetSdkVersion="30" /> |
|||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> |
|||
<application android:label="Avalonia.AndroidTestApplication" android:icon="@drawable/Icon" android:hardwareAccelerated="true"></application> |
|||
<uses-permission android:name="android.permission.INTERNET" /> |
|||
</manifest> |
|||
</manifest> |
|||
|
|||
@ -1,30 +0,0 @@ |
|||
using System.Reflection; |
|||
using System.Runtime.InteropServices; |
|||
|
|||
// General Information about an assembly is controlled through the following
|
|||
// set of attributes. Change these attribute values to modify the information
|
|||
// associated with an assembly.
|
|||
|
|||
[assembly: AssemblyTitle("Avalonia.AndroidTestApplication")] |
|||
[assembly: AssemblyDescription("")] |
|||
[assembly: AssemblyConfiguration("")] |
|||
[assembly: AssemblyCompany("")] |
|||
[assembly: AssemblyProduct("Avalonia.AndroidTestApplication")] |
|||
[assembly: AssemblyCopyright("Copyright © 2015")] |
|||
[assembly: AssemblyTrademark("")] |
|||
[assembly: AssemblyCulture("")] |
|||
[assembly: ComVisible(false)] |
|||
|
|||
// Version information for an assembly consists of the following four values:
|
|||
//
|
|||
// Major Version
|
|||
// Minor Version
|
|||
// Build Number
|
|||
// Revision
|
|||
//
|
|||
// You can specify all the values or you can default the Build and Revision Numbers
|
|||
// by using the '*' as shown below:
|
|||
// [assembly: AssemblyVersion("1.0.*")]
|
|||
|
|||
[assembly: AssemblyVersion("1.0.0.0")] |
|||
[assembly: AssemblyFileVersion("1.0.0.0")] |
|||
@ -1,79 +0,0 @@ |
|||
#pragma warning disable 1591
|
|||
//------------------------------------------------------------------------------
|
|||
// <auto-generated>
|
|||
// This code was generated by a tool.
|
|||
//
|
|||
// Changes to this file may cause incorrect behavior and will be lost if
|
|||
// the code is regenerated.
|
|||
// </auto-generated>
|
|||
//------------------------------------------------------------------------------
|
|||
|
|||
[assembly: global::Android.Runtime.ResourceDesignerAttribute("Avalonia.AndroidTestApplication.Resource", IsApplication=true)] |
|||
|
|||
namespace Avalonia.AndroidTestApplication |
|||
{ |
|||
|
|||
|
|||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "12.1.99.62")] |
|||
public partial class Resource |
|||
{ |
|||
|
|||
static Resource() |
|||
{ |
|||
global::Android.Runtime.ResourceIdManager.UpdateIdValues(); |
|||
} |
|||
|
|||
public static void UpdateIdValues() |
|||
{ |
|||
} |
|||
|
|||
public partial class Attribute |
|||
{ |
|||
|
|||
static Attribute() |
|||
{ |
|||
global::Android.Runtime.ResourceIdManager.UpdateIdValues(); |
|||
} |
|||
|
|||
private Attribute() |
|||
{ |
|||
} |
|||
} |
|||
|
|||
public partial class Drawable |
|||
{ |
|||
|
|||
// aapt resource value: 0x7F010000
|
|||
public const int Icon = 2130771968; |
|||
|
|||
static Drawable() |
|||
{ |
|||
global::Android.Runtime.ResourceIdManager.UpdateIdValues(); |
|||
} |
|||
|
|||
private Drawable() |
|||
{ |
|||
} |
|||
} |
|||
|
|||
public partial class String |
|||
{ |
|||
|
|||
// aapt resource value: 0x7F020000
|
|||
public const int ApplicationName = 2130837504; |
|||
|
|||
// aapt resource value: 0x7F020001
|
|||
public const int Hello = 2130837505; |
|||
|
|||
static String() |
|||
{ |
|||
global::Android.Runtime.ResourceIdManager.UpdateIdValues(); |
|||
} |
|||
|
|||
private String() |
|||
{ |
|||
} |
|||
} |
|||
} |
|||
} |
|||
#pragma warning restore 1591
|
|||
@ -1,11 +0,0 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<configuration> |
|||
<runtime> |
|||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> |
|||
<dependentAssembly> |
|||
<assemblyIdentity name="System.Runtime.InteropServices.WindowsRuntime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> |
|||
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" /> |
|||
</dependentAssembly> |
|||
</assemblyBinding> |
|||
</runtime> |
|||
</configuration> |
|||
@ -0,0 +1,37 @@ |
|||
using Avalonia.Interactivity; |
|||
|
|||
namespace Avalonia.Controls.Primitives |
|||
{ |
|||
/// <summary>
|
|||
/// Allows to customize text searching in <see cref="SelectingItemsControl"/>.
|
|||
/// </summary>
|
|||
public static class TextSearch |
|||
{ |
|||
/// <summary>
|
|||
/// Defines the Text attached property.
|
|||
/// This text will be considered during text search in <see cref="SelectingItemsControl"/> (such as <see cref="ComboBox"/>)
|
|||
/// </summary>
|
|||
public static readonly AttachedProperty<string> TextProperty |
|||
= AvaloniaProperty.RegisterAttached<Interactive, string>("Text", typeof(TextSearch)); |
|||
|
|||
/// <summary>
|
|||
/// Sets the <see cref="TextProperty"/> for a control.
|
|||
/// </summary>
|
|||
/// <param name="control">The control</param>
|
|||
/// <param name="text">The search text to set</param>
|
|||
public static void SetText(Control control, string text) |
|||
{ |
|||
control.SetValue(TextProperty, text); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Gets the <see cref="TextProperty"/> of a control.
|
|||
/// </summary>
|
|||
/// <param name="control">The control</param>
|
|||
/// <returns>The property value</returns>
|
|||
public static string GetText(Control control) |
|||
{ |
|||
return control.GetValue(TextProperty); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,485 @@ |
|||
using System; |
|||
using System.Windows.Input; |
|||
using Avalonia.Controls.Metadata; |
|||
using Avalonia.Controls.Mixins; |
|||
using Avalonia.Controls.Primitives; |
|||
using Avalonia.Input; |
|||
using Avalonia.Interactivity; |
|||
using Avalonia.LogicalTree; |
|||
|
|||
namespace Avalonia.Controls |
|||
{ |
|||
/// <summary>
|
|||
/// A button with primary and secondary parts that can each be pressed separately.
|
|||
/// The primary part behaves like a <see cref="Button"/> and the secondary part opens a flyout.
|
|||
/// </summary>
|
|||
[PseudoClasses(pcFlyoutOpen, pcPressed)] |
|||
public class SplitButton : ContentControl, ICommandSource |
|||
{ |
|||
protected const string pcChecked = ":checked"; |
|||
protected const string pcPressed = ":pressed"; |
|||
protected const string pcFlyoutOpen = ":flyout-open"; |
|||
|
|||
/// <summary>
|
|||
/// Raised when the user presses the primary part of the <see cref="SplitButton"/>.
|
|||
/// </summary>
|
|||
public event EventHandler<RoutedEventArgs> Click |
|||
{ |
|||
add => AddHandler(ClickEvent, value); |
|||
remove => RemoveHandler(ClickEvent, value); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Defines the <see cref="Click"/> event.
|
|||
/// </summary>
|
|||
public static readonly RoutedEvent<RoutedEventArgs> ClickEvent = |
|||
RoutedEvent.Register<SplitButton, RoutedEventArgs>(nameof(Click), RoutingStrategies.Bubble); |
|||
|
|||
/// <summary>
|
|||
/// Defines the <see cref="Command"/> property.
|
|||
/// </summary>
|
|||
public static readonly DirectProperty<SplitButton, ICommand?> CommandProperty = |
|||
Button.CommandProperty.AddOwner<SplitButton>( |
|||
splitButton => splitButton.Command, |
|||
(splitButton, command) => splitButton.Command = command); |
|||
|
|||
/// <summary>
|
|||
/// Defines the <see cref="CommandParameter"/> property.
|
|||
/// </summary>
|
|||
public static readonly StyledProperty<object?> CommandParameterProperty = |
|||
Button.CommandParameterProperty.AddOwner<SplitButton>(); |
|||
|
|||
/// <summary>
|
|||
/// Defines the <see cref="Flyout"/> property
|
|||
/// </summary>
|
|||
public static readonly StyledProperty<FlyoutBase?> FlyoutProperty = |
|||
Button.FlyoutProperty.AddOwner<SplitButton>(); |
|||
|
|||
private ICommand? _Command; |
|||
|
|||
private Button? _primaryButton = null; |
|||
private Button? _secondaryButton = null; |
|||
|
|||
private bool _commandCanExecute = true; |
|||
private bool _isAttachedToLogicalTree = false; |
|||
private bool _isFlyoutOpen = false; |
|||
private bool _isKeyboardPressed = false; |
|||
|
|||
private IDisposable? _flyoutPropertyChangedDisposable; |
|||
|
|||
////////////////////////////////////////////////////////////////////////
|
|||
// Constructor / Destructors
|
|||
////////////////////////////////////////////////////////////////////////
|
|||
|
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="SplitButton"/> class.
|
|||
/// </summary>
|
|||
public SplitButton() |
|||
{ |
|||
} |
|||
|
|||
////////////////////////////////////////////////////////////////////////
|
|||
// Properties
|
|||
////////////////////////////////////////////////////////////////////////
|
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the <see cref="ICommand"/> invoked when the primary part is pressed.
|
|||
/// </summary>
|
|||
public ICommand? Command |
|||
{ |
|||
get => _Command; |
|||
set => SetAndRaise(CommandProperty, ref _Command, value); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets a parameter to be passed to the <see cref="Command"/>.
|
|||
/// </summary>
|
|||
public object? CommandParameter |
|||
{ |
|||
get => GetValue(CommandParameterProperty); |
|||
set => SetValue(CommandParameterProperty, value); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the <see cref="FlyoutBase"/> that is shown when the secondary part is pressed.
|
|||
/// </summary>
|
|||
public FlyoutBase? Flyout |
|||
{ |
|||
get => GetValue(FlyoutProperty); |
|||
set => SetValue(FlyoutProperty, value); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Gets a value indicating whether the button is currently checked.
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// This property exists only for the derived <see cref="ToggleSplitButton"/> and is
|
|||
/// unused (set to false) within <see cref="SplitButton"/>. Doing this allows the
|
|||
/// two controls to share a default style.
|
|||
/// </remarks>
|
|||
internal virtual bool InternalIsChecked => false; |
|||
|
|||
/// <inheritdoc/>
|
|||
protected override bool IsEnabledCore => base.IsEnabledCore && _commandCanExecute; |
|||
|
|||
////////////////////////////////////////////////////////////////////////
|
|||
// Methods
|
|||
////////////////////////////////////////////////////////////////////////
|
|||
|
|||
/// <inheritdoc/>
|
|||
void ICommandSource.CanExecuteChanged(object sender, EventArgs e) => this.CanExecuteChanged(sender, e); |
|||
|
|||
/// <inheritdoc cref="ICommandSource.CanExecuteChanged"/>
|
|||
private void CanExecuteChanged(object? sender, EventArgs e) |
|||
{ |
|||
var canExecute = Command == null || Command.CanExecute(CommandParameter); |
|||
|
|||
if (canExecute != _commandCanExecute) |
|||
{ |
|||
_commandCanExecute = canExecute; |
|||
UpdateIsEffectivelyEnabled(); |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Updates the visual state of the control by applying latest PseudoClasses.
|
|||
/// </summary>
|
|||
protected void UpdatePseudoClasses() |
|||
{ |
|||
PseudoClasses.Set(pcFlyoutOpen, _isFlyoutOpen); |
|||
PseudoClasses.Set(pcPressed, _isKeyboardPressed); |
|||
PseudoClasses.Set(pcChecked, InternalIsChecked); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Opens the secondary button's flyout.
|
|||
/// </summary>
|
|||
protected void OpenFlyout() |
|||
{ |
|||
if (Flyout != null) |
|||
{ |
|||
Flyout.ShowAt(this); |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Closes the secondary button's flyout.
|
|||
/// </summary>
|
|||
protected void CloseFlyout() |
|||
{ |
|||
if (Flyout != null) |
|||
{ |
|||
Flyout.Hide(); |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Registers all flyout events.
|
|||
/// </summary>
|
|||
/// <param name="flyout">The flyout to connect events to.</param>
|
|||
private void RegisterFlyoutEvents(FlyoutBase? flyout) |
|||
{ |
|||
if (flyout != null) |
|||
{ |
|||
flyout.Opened += Flyout_Opened; |
|||
flyout.Closed += Flyout_Closed; |
|||
|
|||
_flyoutPropertyChangedDisposable = flyout.GetPropertyChangedObservable(FlyoutBase.PlacementProperty).Subscribe(Flyout_PlacementPropertyChanged); |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Explicitly unregisters all flyout events.
|
|||
/// </summary>
|
|||
/// <param name="flyout">The flyout to disconnect events from.</param>
|
|||
private void UnregisterFlyoutEvents(FlyoutBase? flyout) |
|||
{ |
|||
if (flyout != null) |
|||
{ |
|||
flyout.Opened -= Flyout_Opened; |
|||
flyout.Closed -= Flyout_Closed; |
|||
|
|||
_flyoutPropertyChangedDisposable?.Dispose(); |
|||
_flyoutPropertyChangedDisposable = null; |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Explicitly unregisters all events related to the two buttons in OnApplyTemplate().
|
|||
/// </summary>
|
|||
private void UnregisterEvents() |
|||
{ |
|||
if (_primaryButton != null) |
|||
{ |
|||
_primaryButton.Click -= PrimaryButton_Click; |
|||
} |
|||
|
|||
if (_secondaryButton != null) |
|||
{ |
|||
_secondaryButton.Click -= SecondaryButton_Click; |
|||
} |
|||
} |
|||
|
|||
////////////////////////////////////////////////////////////////////////
|
|||
// OnEvent Overridable Methods
|
|||
////////////////////////////////////////////////////////////////////////
|
|||
|
|||
/// <inheritdoc/>
|
|||
protected override void OnApplyTemplate(TemplateAppliedEventArgs e) |
|||
{ |
|||
UnregisterEvents(); |
|||
UnregisterFlyoutEvents(Flyout); |
|||
|
|||
_primaryButton = e.NameScope.Find<Button>("PART_PrimaryButton"); |
|||
_secondaryButton = e.NameScope.Find<Button>("PART_SecondaryButton"); |
|||
|
|||
if (_primaryButton != null) |
|||
{ |
|||
_primaryButton.Click += PrimaryButton_Click; |
|||
} |
|||
|
|||
if (_secondaryButton != null) |
|||
{ |
|||
_secondaryButton.Click += SecondaryButton_Click; |
|||
} |
|||
|
|||
RegisterFlyoutEvents(Flyout); |
|||
UpdatePseudoClasses(); |
|||
} |
|||
|
|||
/// <inheritdoc/>
|
|||
protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e) |
|||
{ |
|||
base.OnAttachedToLogicalTree(e); |
|||
|
|||
if (Command != null) |
|||
{ |
|||
Command.CanExecuteChanged += CanExecuteChanged; |
|||
CanExecuteChanged(this, EventArgs.Empty); |
|||
} |
|||
|
|||
_isAttachedToLogicalTree = true; |
|||
} |
|||
|
|||
/// <inheritdoc/>
|
|||
protected override void OnDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs e) |
|||
{ |
|||
base.OnDetachedFromLogicalTree(e); |
|||
|
|||
if (Command != null) |
|||
{ |
|||
Command.CanExecuteChanged -= CanExecuteChanged; |
|||
} |
|||
|
|||
_isAttachedToLogicalTree = false; |
|||
} |
|||
|
|||
/// <inheritdoc/>
|
|||
protected override void OnPropertyChanged<T>(AvaloniaPropertyChangedEventArgs<T> e) |
|||
{ |
|||
if (e.Property == CommandProperty) |
|||
{ |
|||
if (_isAttachedToLogicalTree) |
|||
{ |
|||
// Must unregister events here while a reference to the old command still exists
|
|||
if (e.OldValue.GetValueOrDefault() is ICommand oldCommand) |
|||
{ |
|||
oldCommand.CanExecuteChanged -= CanExecuteChanged; |
|||
} |
|||
|
|||
if (e.NewValue.GetValueOrDefault() is ICommand newCommand) |
|||
{ |
|||
newCommand.CanExecuteChanged += CanExecuteChanged; |
|||
} |
|||
} |
|||
|
|||
CanExecuteChanged(this, EventArgs.Empty); |
|||
} |
|||
else if (e.Property == CommandParameterProperty) |
|||
{ |
|||
CanExecuteChanged(this, EventArgs.Empty); |
|||
} |
|||
else if (e.Property == FlyoutProperty) |
|||
{ |
|||
var oldFlyout = e.OldValue.GetValueOrDefault() as FlyoutBase; |
|||
var newFlyout = e.NewValue.GetValueOrDefault() as FlyoutBase; |
|||
|
|||
// If flyout is changed while one is already open, make sure we
|
|||
// close the old one first
|
|||
// This is the same behavior as Button
|
|||
if (oldFlyout != null && |
|||
oldFlyout.IsOpen) |
|||
{ |
|||
oldFlyout.Hide(); |
|||
} |
|||
|
|||
// Must unregister events here while a reference to the old flyout still exists
|
|||
if (oldFlyout != null) |
|||
{ |
|||
UnregisterFlyoutEvents(oldFlyout); |
|||
} |
|||
|
|||
if (newFlyout != null) |
|||
{ |
|||
RegisterFlyoutEvents(newFlyout); |
|||
} |
|||
|
|||
UpdatePseudoClasses(); |
|||
} |
|||
|
|||
base.OnPropertyChanged(e); |
|||
} |
|||
|
|||
/// <inheritdoc/>
|
|||
protected override void OnKeyDown(KeyEventArgs e) |
|||
{ |
|||
var key = e.Key; |
|||
|
|||
if (key == Key.Space || key == Key.Enter) // Key.GamepadA is not currently supported
|
|||
{ |
|||
_isKeyboardPressed = true; |
|||
UpdatePseudoClasses(); |
|||
} |
|||
|
|||
base.OnKeyDown(e); |
|||
} |
|||
|
|||
/// <inheritdoc/>
|
|||
protected override void OnKeyUp(KeyEventArgs e) |
|||
{ |
|||
var key = e.Key; |
|||
|
|||
if (key == Key.Space || key == Key.Enter) // Key.GamepadA is not currently supported
|
|||
{ |
|||
_isKeyboardPressed = false; |
|||
UpdatePseudoClasses(); |
|||
|
|||
// Consider this a click on the primary button
|
|||
if (IsEffectivelyEnabled) |
|||
{ |
|||
OnClickPrimary(null); |
|||
e.Handled = true; |
|||
} |
|||
} |
|||
else if (key == Key.Down && e.KeyModifiers.HasAllFlags(KeyModifiers.Alt) && IsEffectivelyEnabled) |
|||
{ |
|||
OpenFlyout(); |
|||
e.Handled = true; |
|||
} |
|||
else if (key == Key.F4 && IsEffectivelyEnabled) |
|||
{ |
|||
OpenFlyout(); |
|||
e.Handled = true; |
|||
} |
|||
else if (e.Key == Key.Escape && _isFlyoutOpen) |
|||
{ |
|||
// If Flyout doesn't have focusable content, close the flyout here
|
|||
// This is the same behavior as Button
|
|||
CloseFlyout(); |
|||
e.Handled = true; |
|||
} |
|||
|
|||
base.OnKeyUp(e); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Invokes the <see cref="Click"/> event when the primary button part is clicked.
|
|||
/// </summary>
|
|||
/// <param name="e">The event args from the internal Click event.</param>
|
|||
protected virtual void OnClickPrimary(RoutedEventArgs? e) |
|||
{ |
|||
// Note: It is not currently required to check enabled status; however, this is a failsafe
|
|||
if (IsEffectivelyEnabled) |
|||
{ |
|||
var eventArgs = new RoutedEventArgs(ClickEvent); |
|||
RaiseEvent(eventArgs); |
|||
|
|||
if (!eventArgs.Handled && Command?.CanExecute(CommandParameter) == true) |
|||
{ |
|||
Command.Execute(CommandParameter); |
|||
eventArgs.Handled = true; |
|||
} |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Invoked when the secondary button part is clicked.
|
|||
/// </summary>
|
|||
/// <param name="e">The event args from the internal Click event.</param>
|
|||
protected virtual void OnClickSecondary(RoutedEventArgs? e) |
|||
{ |
|||
// Note: It is not currently required to check enabled status; however, this is a failsafe
|
|||
if (IsEffectivelyEnabled) |
|||
{ |
|||
OpenFlyout(); |
|||
} |
|||
} |
|||
|
|||
////////////////////////////////////////////////////////////////////////
|
|||
// Event Handling
|
|||
////////////////////////////////////////////////////////////////////////
|
|||
|
|||
/// <summary>
|
|||
/// Event handler for when the internal primary button part is pressed.
|
|||
/// </summary>
|
|||
private void PrimaryButton_Click(object? sender, RoutedEventArgs e) |
|||
{ |
|||
// Handle internal button click, so it won't bubble outside together with SplitButton.ClickEvent.
|
|||
e.Handled = true; |
|||
OnClickPrimary(e); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Event handler for when the internal secondary button part is pressed.
|
|||
/// </summary>
|
|||
private void SecondaryButton_Click(object? sender, RoutedEventArgs e) |
|||
{ |
|||
// Handle internal button click, so it won't bubble outside.
|
|||
e.Handled = true; |
|||
OnClickSecondary(e); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Called when the <see cref="FlyoutBase.Placement"/> property changes.
|
|||
/// </summary>
|
|||
private void Flyout_PlacementPropertyChanged(AvaloniaPropertyChangedEventArgs e) |
|||
{ |
|||
UpdatePseudoClasses(); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Event handler for when the split button's flyout is opened.
|
|||
/// </summary>
|
|||
private void Flyout_Opened(object? sender, EventArgs e) |
|||
{ |
|||
var flyout = sender as FlyoutBase; |
|||
|
|||
// It is possible to share flyouts among multiple controls including SplitButton.
|
|||
// This can cause a problem here since all controls that share a flyout receive
|
|||
// the same Opened/Closed events at the same time.
|
|||
// For SplitButton that means they all would be updating their pseudoclasses accordingly.
|
|||
// In other words, all SplitButtons with a shared Flyout would have the backgrounds changed together.
|
|||
// To fix this, only continue here if the Flyout target matches this SplitButton instance.
|
|||
if (object.ReferenceEquals(flyout?.Target, this)) |
|||
{ |
|||
_isFlyoutOpen = true; |
|||
UpdatePseudoClasses(); |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Event handler for when the split button's flyout is closed.
|
|||
/// </summary>
|
|||
private void Flyout_Closed(object? sender, EventArgs e) |
|||
{ |
|||
var flyout = sender as FlyoutBase; |
|||
|
|||
// See comments in Flyout_Opened
|
|||
if (object.ReferenceEquals(flyout?.Target, this)) |
|||
{ |
|||
_isFlyoutOpen = false; |
|||
UpdatePseudoClasses(); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,125 @@ |
|||
using System; |
|||
|
|||
using Avalonia.Controls.Metadata; |
|||
using Avalonia.Controls.Primitives; |
|||
using Avalonia.Interactivity; |
|||
using Avalonia.Styling; |
|||
|
|||
namespace Avalonia.Controls |
|||
{ |
|||
/// <summary>
|
|||
/// A button with primary and secondary parts that can each be pressed separately.
|
|||
/// The primary part behaves like a <see cref="ToggleButton"/> with two states and
|
|||
/// the secondary part opens a flyout.
|
|||
/// </summary>
|
|||
[PseudoClasses(pcChecked)] |
|||
public class ToggleSplitButton : SplitButton, IStyleable |
|||
{ |
|||
/// <summary>
|
|||
/// Raised when the <see cref="IsChecked"/> property value changes.
|
|||
/// </summary>
|
|||
public event EventHandler<RoutedEventArgs> IsCheckedChanged |
|||
{ |
|||
add => AddHandler(IsCheckedChangedEvent, value); |
|||
remove => RemoveHandler(IsCheckedChangedEvent, value); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Defines the <see cref="IsCheckedChanged"/> event.
|
|||
/// </summary>
|
|||
public static readonly RoutedEvent<RoutedEventArgs> IsCheckedChangedEvent = |
|||
RoutedEvent.Register<ToggleSplitButton, RoutedEventArgs>( |
|||
nameof(IsCheckedChanged), |
|||
RoutingStrategies.Bubble); |
|||
|
|||
/// <summary>
|
|||
/// Defines the <see cref="IsChecked"/> property.
|
|||
/// </summary>
|
|||
public static readonly StyledProperty<bool> IsCheckedProperty = |
|||
AvaloniaProperty.Register<ToggleSplitButton, bool>( |
|||
nameof(IsChecked)); |
|||
|
|||
////////////////////////////////////////////////////////////////////////
|
|||
// Constructor / Destructors
|
|||
////////////////////////////////////////////////////////////////////////
|
|||
|
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="ToggleSplitButton"/> class.
|
|||
/// </summary>
|
|||
public ToggleSplitButton() |
|||
{ |
|||
} |
|||
|
|||
////////////////////////////////////////////////////////////////////////
|
|||
// Properties
|
|||
////////////////////////////////////////////////////////////////////////
|
|||
|
|||
/// <summary>
|
|||
/// Gets or sets a value indicating whether the <see cref="ToggleSplitButton"/> is checked.
|
|||
/// </summary>
|
|||
public bool IsChecked |
|||
{ |
|||
get => GetValue(IsCheckedProperty); |
|||
set => SetValue(IsCheckedProperty, value); |
|||
} |
|||
|
|||
/// <inheritdoc/>
|
|||
internal override bool InternalIsChecked => IsChecked; |
|||
|
|||
/// <inheritdoc/>
|
|||
/// <remarks>
|
|||
/// Both <see cref="ToggleSplitButton"/> and <see cref="SplitButton"/> share
|
|||
/// the same exact default style.
|
|||
/// </remarks>
|
|||
Type IStyleable.StyleKey => typeof(SplitButton); |
|||
|
|||
////////////////////////////////////////////////////////////////////////
|
|||
// Methods
|
|||
////////////////////////////////////////////////////////////////////////
|
|||
|
|||
/// <summary>
|
|||
/// Toggles the <see cref="IsChecked"/> property between true and false.
|
|||
/// </summary>
|
|||
protected void Toggle() |
|||
{ |
|||
IsChecked = !IsChecked; |
|||
} |
|||
|
|||
////////////////////////////////////////////////////////////////////////
|
|||
// OnEvent Overridable Methods
|
|||
////////////////////////////////////////////////////////////////////////
|
|||
|
|||
/// <inheritdoc/>
|
|||
protected override void OnPropertyChanged<T>(AvaloniaPropertyChangedEventArgs<T> e) |
|||
{ |
|||
if (e.Property == IsCheckedProperty) |
|||
{ |
|||
OnIsCheckedChanged(); |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Invokes the <see cref="IsCheckedChanged"/> event when the <see cref="IsChecked"/>
|
|||
/// property changes.
|
|||
/// </summary>
|
|||
protected virtual void OnIsCheckedChanged() |
|||
{ |
|||
// IsLoaded check
|
|||
if (Parent is not null) |
|||
{ |
|||
var eventArgs = new RoutedEventArgs(IsCheckedChangedEvent); |
|||
RaiseEvent(eventArgs); |
|||
} |
|||
|
|||
UpdatePseudoClasses(); |
|||
} |
|||
|
|||
/// <inheritdoc/>
|
|||
protected override void OnClickPrimary(RoutedEventArgs? e) |
|||
{ |
|||
Toggle(); |
|||
|
|||
base.OnClickPrimary(e); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,96 @@ |
|||
using System; |
|||
using System.Threading; |
|||
using Avalonia.Animation; |
|||
using Avalonia.Controls.Templates; |
|||
using Avalonia.Threading; |
|||
|
|||
namespace Avalonia.Controls; |
|||
|
|||
/// <summary>
|
|||
/// Displays <see cref="ContentControl.Content"/> according to a <see cref="FuncDataTemplate"/>.
|
|||
/// Uses <see cref="PageTransition"/> to move between the old and new content values.
|
|||
/// </summary>
|
|||
public class TransitioningContentControl : ContentControl |
|||
{ |
|||
private CancellationTokenSource? _lastTransitionCts; |
|||
private object? _currentContent; |
|||
|
|||
/// <summary>
|
|||
/// Defines the <see cref="PageTransition"/> property.
|
|||
/// </summary>
|
|||
public static readonly StyledProperty<IPageTransition?> PageTransitionProperty = |
|||
AvaloniaProperty.Register<TransitioningContentControl, IPageTransition?>(nameof(PageTransition), |
|||
new CrossFade(TimeSpan.FromSeconds(0.125))); |
|||
|
|||
/// <summary>
|
|||
/// Defines the <see cref="CurrentContent"/> property.
|
|||
/// </summary>
|
|||
public static readonly DirectProperty<TransitioningContentControl, object?> CurrentContentProperty = |
|||
AvaloniaProperty.RegisterDirect<TransitioningContentControl, object?>(nameof(CurrentContent), |
|||
o => o.CurrentContent); |
|||
|
|||
/// <summary>
|
|||
/// Gets or sets the animation played when content appears and disappears.
|
|||
/// </summary>
|
|||
public IPageTransition? PageTransition |
|||
{ |
|||
get => GetValue(PageTransitionProperty); |
|||
set => SetValue(PageTransitionProperty, value); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Gets the content currently displayed on the screen.
|
|||
/// </summary>
|
|||
public object? CurrentContent |
|||
{ |
|||
get => _currentContent; |
|||
private set => SetAndRaise(CurrentContentProperty, ref _currentContent, value); |
|||
} |
|||
|
|||
protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e) |
|||
{ |
|||
base.OnAttachedToVisualTree(e); |
|||
|
|||
Dispatcher.UIThread.Post(() => UpdateContentWithTransition(Content)); |
|||
} |
|||
|
|||
protected override void OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e) |
|||
{ |
|||
base.OnDetachedFromVisualTree(e); |
|||
|
|||
_lastTransitionCts?.Cancel(); |
|||
} |
|||
|
|||
protected override void OnPropertyChanged<T>(AvaloniaPropertyChangedEventArgs<T> change) |
|||
{ |
|||
base.OnPropertyChanged(change); |
|||
|
|||
if (change.Property == ContentProperty) |
|||
{ |
|||
Dispatcher.UIThread.Post(() => UpdateContentWithTransition(Content)); |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Updates the content with transitions.
|
|||
/// </summary>
|
|||
/// <param name="content">New content to set.</param>
|
|||
private async void UpdateContentWithTransition(object? content) |
|||
{ |
|||
if (VisualRoot is null) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
_lastTransitionCts?.Cancel(); |
|||
_lastTransitionCts = new CancellationTokenSource(); |
|||
|
|||
if (PageTransition != null) |
|||
await PageTransition.Start(this, null, true, _lastTransitionCts.Token); |
|||
|
|||
CurrentContent = content; |
|||
|
|||
if (PageTransition != null) |
|||
await PageTransition.Start(null, this, true, _lastTransitionCts.Token); |
|||
} |
|||
} |
|||
@ -0,0 +1,53 @@ |
|||
namespace Avalonia.MicroCom |
|||
{ |
|||
public abstract class CallbackBase : IUnknown, IMicroComShadowContainer |
|||
{ |
|||
private readonly object _lock = new object(); |
|||
private bool _referencedFromManaged = true; |
|||
private bool _referencedFromNative = false; |
|||
private bool _destroyed; |
|||
|
|||
public bool IsDestroyed => _destroyed; |
|||
|
|||
protected virtual void Destroyed() |
|||
{ |
|||
|
|||
} |
|||
|
|||
public void Dispose() |
|||
{ |
|||
lock (_lock) |
|||
{ |
|||
_referencedFromManaged = false; |
|||
DestroyIfNeeded(); |
|||
} |
|||
} |
|||
|
|||
void DestroyIfNeeded() |
|||
{ |
|||
if(_destroyed) |
|||
return; |
|||
if (_referencedFromManaged == false && _referencedFromNative == false) |
|||
{ |
|||
_destroyed = true; |
|||
Destroyed(); |
|||
} |
|||
} |
|||
|
|||
public MicroComShadow Shadow { get; set; } |
|||
public void OnReferencedFromNative() |
|||
{ |
|||
lock (_lock) |
|||
_referencedFromNative = true; |
|||
} |
|||
|
|||
public void OnUnreferencedFromNative() |
|||
{ |
|||
lock (_lock) |
|||
{ |
|||
_referencedFromNative = false; |
|||
DestroyIfNeeded(); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,271 @@ |
|||
<Styles xmlns="https://github.com/avaloniaui" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
x:CompileBindings="True" |
|||
xmlns:converters="using:Avalonia.Controls.Converters"> |
|||
|
|||
<!-- This style is heavily based on the Fluent v1 style. |
|||
The base resources are switched out along with a few minor changes such as Padding, CornerRadius. --> |
|||
|
|||
<Design.PreviewWith> |
|||
<Border Padding="20"> |
|||
<SplitButton /> |
|||
</Border> |
|||
</Design.PreviewWith> |
|||
|
|||
<Styles.Resources> |
|||
<x:Double x:Key="SplitButtonPrimaryButtonSize">24</x:Double> |
|||
<x:Double x:Key="SplitButtonSecondaryButtonSize">24</x:Double> |
|||
<x:Double x:Key="SplitButtonSeparatorWidth">1</x:Double> |
|||
<Thickness x:Key="SplitButtonBorderThemeThickness">1</Thickness> |
|||
|
|||
<converters:MarginMultiplierConverter x:Key="PrimaryButtonBorderMultiplier" Left="True" Top="True" Bottom="True" Indent="1" /> |
|||
<converters:MarginMultiplierConverter x:Key="SecondaryButtonBorderMultiplier" Right="True" Top="True" Bottom="True" Indent="1" /> |
|||
<converters:MarginMultiplierConverter x:Key="SeparatorBorderMultiplier" Top="True" Bottom="True" Indent="1" /> |
|||
<converters:CornerRadiusFilterConverter x:Key="TopCornerRadiusFilterConverter" Filter="TopLeft, TopRight"/> |
|||
<converters:CornerRadiusFilterConverter x:Key="RightCornerRadiusFilterConverter" Filter="TopRight, BottomRight"/> |
|||
<converters:CornerRadiusFilterConverter x:Key="BottomCornerRadiusFilterConverter" Filter="BottomLeft, BottomRight"/> |
|||
<converters:CornerRadiusFilterConverter x:Key="LeftCornerRadiusFilterConverter" Filter="TopLeft, BottomLeft"/> |
|||
|
|||
<SolidColorBrush x:Key="SplitButtonBackground" Color="{DynamicResource ThemeControlMidColor}" /> |
|||
<SolidColorBrush x:Key="SplitButtonBackgroundPointerOver" Color="{DynamicResource ThemeControlMidColor}" /> |
|||
<SolidColorBrush x:Key="SplitButtonBackgroundPressed" Color="{DynamicResource ThemeBorderHighColor}" /> |
|||
<SolidColorBrush x:Key="SplitButtonBackgroundDisabled" Color="{DynamicResource ThemeControlMidColor}" Opacity="{DynamicResource ThemeDisabledOpacity}" /> |
|||
<SolidColorBrush x:Key="SplitButtonBackgroundChecked" Color="{DynamicResource ThemeBorderHighColor}" /> |
|||
<SolidColorBrush x:Key="SplitButtonBackgroundCheckedPointerOver" Color="{DynamicResource ThemeBorderHighColor}" /> |
|||
<SolidColorBrush x:Key="SplitButtonBackgroundCheckedPressed" Color="{DynamicResource ThemeBorderHighColor}" /> |
|||
<SolidColorBrush x:Key="SplitButtonBackgroundCheckedDisabled" Color="{DynamicResource ThemeControlHighColor}" Opacity="{DynamicResource ThemeDisabledOpacity}" /> |
|||
|
|||
<SolidColorBrush x:Key="SplitButtonForeground" Color="{DynamicResource ThemeForegroundColor}" /> |
|||
<SolidColorBrush x:Key="SplitButtonForegroundPointerOver" Color="{DynamicResource ThemeForegroundColor}" /> |
|||
<SolidColorBrush x:Key="SplitButtonForegroundPressed" Color="{DynamicResource ThemeForegroundColor}" /> |
|||
<SolidColorBrush x:Key="SplitButtonForegroundDisabled" Color="{DynamicResource ThemeForegroundColor}" /> |
|||
<SolidColorBrush x:Key="SplitButtonForegroundChecked" Color="{DynamicResource ThemeForegroundColor}" /> |
|||
<SolidColorBrush x:Key="SplitButtonForegroundCheckedPointerOver" Color="{DynamicResource ThemeForegroundColor}" /> |
|||
<SolidColorBrush x:Key="SplitButtonForegroundCheckedPressed" Color="{DynamicResource ThemeForegroundColor}" /> |
|||
<SolidColorBrush x:Key="SplitButtonForegroundCheckedDisabled" Color="{DynamicResource ThemeForegroundColor}" /> |
|||
|
|||
<SolidColorBrush x:Key="SplitButtonBorderBrush" Color="{DynamicResource ThemeBorderLowColor}" /> |
|||
<SolidColorBrush x:Key="SplitButtonBorderBrushPointerOver" Color="{DynamicResource ThemeBorderMidColor}" /> |
|||
<SolidColorBrush x:Key="SplitButtonBorderBrushPressed" Color="{DynamicResource ThemeBorderLowColor}" /> |
|||
<SolidColorBrush x:Key="SplitButtonBorderBrushDisabled" Color="{DynamicResource ThemeBorderLowColor}" /> |
|||
<SolidColorBrush x:Key="SplitButtonBorderBrushChecked" Color="{DynamicResource ThemeBorderMidColor}" /> |
|||
<SolidColorBrush x:Key="SplitButtonBorderBrushCheckedPointerOver" Color="{DynamicResource ThemeBorderMidColor}" /> |
|||
<SolidColorBrush x:Key="SplitButtonBorderBrushCheckedPressed" Color="{DynamicResource ThemeControlHighColor}" /> |
|||
<SolidColorBrush x:Key="SplitButtonBorderBrushCheckedDisabled" Color="{DynamicResource ThemeControlMidColor}" Opacity="{DynamicResource ThemeDisabledOpacity}" /> |
|||
</Styles.Resources> |
|||
|
|||
<Style Selector="SplitButton"> |
|||
<Setter Property="Background" Value="{DynamicResource SplitButtonBackground}" /> |
|||
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForeground}" /> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource SplitButtonBorderBrush}" /> |
|||
<Setter Property="BorderThickness" Value="{DynamicResource SplitButtonBorderThemeThickness}" /> |
|||
<Setter Property="HorizontalAlignment" Value="Left" /> |
|||
<Setter Property="VerticalAlignment" Value="Center" /> |
|||
<!--<Setter Property="UseSystemFocusVisuals" Value="True" /> |
|||
<Setter Property="FocusVisualMargin" Value="-3" />--> |
|||
<Setter Property="KeyboardNavigation.IsTabStop" Value="True" /> |
|||
<Setter Property="Focusable" Value="True" /> |
|||
<Setter Property="Padding" Value="4" /> |
|||
<Setter Property="CornerRadius" Value="0" /> |
|||
<Setter Property="Template"> |
|||
<Setter.Value> |
|||
<ControlTemplate> |
|||
<Grid> |
|||
<Grid.ColumnDefinitions> |
|||
<ColumnDefinition Width="*" /> |
|||
<ColumnDefinition Width="Auto" /> |
|||
<ColumnDefinition Width="Auto" /> |
|||
</Grid.ColumnDefinitions> |
|||
|
|||
<Button x:Name="PART_PrimaryButton" |
|||
Grid.Column="0" |
|||
MinWidth="{DynamicResource SplitButtonPrimaryButtonSize}" |
|||
Foreground="{TemplateBinding Foreground}" |
|||
Background="{TemplateBinding Background}" |
|||
BorderThickness="{TemplateBinding BorderThickness, Converter={StaticResource PrimaryButtonBorderMultiplier}}" |
|||
BorderBrush="{TemplateBinding BorderBrush}" |
|||
Content="{TemplateBinding Content}" |
|||
ContentTemplate="{TemplateBinding ContentTemplate}" |
|||
Command="{TemplateBinding Command}" |
|||
CommandParameter="{TemplateBinding CommandParameter}" |
|||
FontFamily="{TemplateBinding FontFamily}" |
|||
FontSize="{TemplateBinding FontSize}" |
|||
FontWeight="{TemplateBinding FontWeight}" |
|||
HorizontalAlignment="Stretch" |
|||
VerticalAlignment="Stretch" |
|||
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" |
|||
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" |
|||
Padding="{TemplateBinding Padding}" |
|||
Focusable="False" |
|||
KeyboardNavigation.IsTabStop="False" /> |
|||
|
|||
<Border x:Name="SeparatorBorder" |
|||
Grid.Column="1" |
|||
Background="Transparent" |
|||
Width="{DynamicResource SplitButtonSeparatorWidth}" |
|||
BorderThickness="{TemplateBinding BorderThickness, Converter={StaticResource SeparatorBorderMultiplier}}" |
|||
BorderBrush="{TemplateBinding BorderBrush}" /> |
|||
|
|||
<Button x:Name="PART_SecondaryButton" |
|||
Grid.Column="2" |
|||
MinWidth="{DynamicResource SplitButtonSecondaryButtonSize}" |
|||
BorderBrush="{TemplateBinding BorderBrush}" |
|||
Foreground="{TemplateBinding Foreground}" |
|||
Background="{TemplateBinding Background}" |
|||
BorderThickness="{TemplateBinding BorderThickness, Converter={StaticResource SecondaryButtonBorderMultiplier}}" |
|||
Padding="0" |
|||
HorizontalContentAlignment="Center" |
|||
VerticalContentAlignment="Center" |
|||
HorizontalAlignment="Stretch" |
|||
VerticalAlignment="Stretch" |
|||
Focusable="False" |
|||
KeyboardNavigation.IsTabStop="False" /> |
|||
</Grid> |
|||
</ControlTemplate> |
|||
</Setter.Value> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
<!-- Default overridable styles --> |
|||
<Style Selector="SplitButton /template/ Button#PART_PrimaryButton"> |
|||
<Setter Property="CornerRadius" Value="{TemplateBinding CornerRadius, Converter={StaticResource LeftCornerRadiusFilterConverter}}" /> |
|||
</Style> |
|||
<Style Selector="SplitButton /template/ Button#PART_SecondaryButton"> |
|||
<Setter Property="CornerRadius" Value="{TemplateBinding CornerRadius, Converter={StaticResource RightCornerRadiusFilterConverter}}" /> |
|||
<Setter Property="Content"> |
|||
<Template> |
|||
<PathIcon Height="12" |
|||
Width="12" |
|||
Data="M1939 486L2029 576L1024 1581L19 576L109 486L1024 1401L1939 486Z" /> |
|||
</Template> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
<!-- Primary and Secondary buttons PointerOver State --> |
|||
<Style Selector="SplitButton /template/ Button#PART_PrimaryButton:pointerover /template/ ContentPresenter, |
|||
SplitButton /template/ Button#PART_SecondaryButton:pointerover /template/ ContentPresenter"> |
|||
<Setter Property="Border.Background" Value="{DynamicResource SplitButtonBackgroundPointerOver}" /> |
|||
<Setter Property="Border.BorderBrush" Value="{DynamicResource SplitButtonBorderBrushPointerOver}" /> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource SplitButtonForegroundPointerOver}" /> |
|||
</Style> |
|||
<Style Selector="SplitButton /template/ Button#PART_SecondaryButton:pointerover PathIcon"> |
|||
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundPointerOver}" /> |
|||
</Style> |
|||
|
|||
<!-- Primary and Secondary buttons Pressed State --> |
|||
<Style Selector="SplitButton /template/ Button#PART_PrimaryButton:pressed /template/ ContentPresenter, |
|||
SplitButton /template/ Button#PART_SecondaryButton:pressed /template/ ContentPresenter"> |
|||
<Setter Property="Border.Background" Value="{DynamicResource SplitButtonBackgroundPressed}" /> |
|||
<Setter Property="Border.BorderBrush" Value="{DynamicResource SplitButtonBorderBrushPressed}" /> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource SplitButtonForegroundPressed}" /> |
|||
</Style> |
|||
<Style Selector="SplitButton /template/ Button#PART_SecondaryButton:pressed PathIcon"> |
|||
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundPressed}" /> |
|||
</Style> |
|||
|
|||
<!-- SplitButton Pressed State --> |
|||
<Style Selector="SplitButton:pressed /template/ Button#PART_PrimaryButton /template/ ContentPresenter, |
|||
SplitButton:pressed /template/ Button#PART_SecondaryButton /template/ ContentPresenter, |
|||
SplitButton:pressed /template/ Border#SeparatorBorder"> |
|||
<Setter Property="Border.Background" Value="{DynamicResource SplitButtonBackgroundPressed}" /> |
|||
<Setter Property="Border.BorderBrush" Value="{DynamicResource SplitButtonBorderBrushPressed}" /> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource SplitButtonForegroundPressed}" /> |
|||
</Style> |
|||
<Style Selector="SplitButton:pressed /template/ Button#PART_SecondaryButton PathIcon"> |
|||
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundPressed}" /> |
|||
</Style> |
|||
|
|||
<!-- Primary and Secondary buttons Flyout Open State --> |
|||
<Style Selector="SplitButton:flyout-open /template/ Button#PART_PrimaryButton /template/ ContentPresenter, |
|||
SplitButton:flyout-open /template/ Button#PART_SecondaryButton /template/ ContentPresenter, |
|||
SplitButton:flyout-open /template/ Border#SeparatorBorder"> |
|||
<Setter Property="Border.Background" Value="{DynamicResource SplitButtonBackgroundPressed}" /> |
|||
<Setter Property="Border.BorderBrush" Value="{DynamicResource SplitButtonBorderBrushPressed}" /> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource SplitButtonForegroundPressed}" /> |
|||
</Style> |
|||
<Style Selector="SplitButton:flyout-open /template/ Button#PART_SecondaryButton PathIcon"> |
|||
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundPressed}" /> |
|||
</Style> |
|||
|
|||
<!-- Disabled State --> |
|||
<Style Selector="SplitButton:disabled /template/ Button#PART_PrimaryButton /template/ ContentPresenter, |
|||
SplitButton:disabled /template/ Button#PART_SecondaryButton /template/ ContentPresenter, |
|||
SplitButton:disabled /template/ Border#SeparatorBorder"> |
|||
<Setter Property="Border.Background" Value="{DynamicResource SplitButtonBackgroundDisabled}" /> |
|||
<Setter Property="Border.BorderBrush" Value="{DynamicResource SplitButtonBorderBrushDisabled}" /> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource SplitButtonForegroundDisabled}" /> |
|||
</Style> |
|||
<Style Selector="SplitButton:disabled /template/ Button#PART_SecondaryButton PathIcon"> |
|||
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundDisabled}" /> |
|||
</Style> |
|||
|
|||
<!-- Checked State --> |
|||
<Style Selector="SplitButton:checked /template/ Button#PART_PrimaryButton /template/ ContentPresenter, |
|||
SplitButton:checked /template/ Button#PART_SecondaryButton /template/ ContentPresenter, |
|||
SplitButton:checked /template/ Border#SeparatorBorder"> |
|||
<Setter Property="Border.Background" Value="{DynamicResource SplitButtonBackgroundChecked}" /> |
|||
<Setter Property="Border.BorderBrush" Value="{DynamicResource SplitButtonBorderBrushChecked}" /> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource SplitButtonForegroundChecked}" /> |
|||
</Style> |
|||
<Style Selector="SplitButton:checked /template/ Button#PART_SecondaryButton PathIcon"> |
|||
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundChecked}" /> |
|||
</Style> |
|||
|
|||
<!-- Checked PointerOver State --> |
|||
<Style Selector="SplitButton:checked /template/ Button#PART_PrimaryButton:pointerover /template/ ContentPresenter, |
|||
SplitButton:checked /template/ Button#PART_SecondaryButton:pointerover /template/ ContentPresenter"> |
|||
<Setter Property="Border.Background" Value="{DynamicResource SplitButtonBackgroundCheckedPointerOver}" /> |
|||
<Setter Property="Border.BorderBrush" Value="{DynamicResource SplitButtonBorderBrushCheckedPointerOver}" /> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource SplitButtonForegroundCheckedPointerOver}" /> |
|||
</Style> |
|||
<Style Selector="SplitButton:checked /template/ Button#PART_SecondaryButton:pointerover PathIcon"> |
|||
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundCheckedPointerOver}" /> |
|||
</Style> |
|||
|
|||
<!-- Checked Pressed State --> |
|||
<Style Selector="SplitButton:checked /template/ Button#PART_PrimaryButton:pressed /template/ ContentPresenter, |
|||
SplitButton:checked /template/ Button#PART_SecondaryButton:pressed /template/ ContentPresenter"> |
|||
<Setter Property="Border.Background" Value="{DynamicResource SplitButtonBackgroundCheckedPressed}" /> |
|||
<Setter Property="Border.BorderBrush" Value="{DynamicResource SplitButtonBorderBrushCheckedPressed}" /> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource SplitButtonForegroundCheckedPressed}" /> |
|||
</Style> |
|||
<Style Selector="SplitButton:checked /template/ Button#PART_SecondaryButton:pressed PathIcon"> |
|||
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundCheckedPressed}" /> |
|||
</Style> |
|||
|
|||
<!-- SplitButton Checked Pressed State --> |
|||
<Style Selector="SplitButton:pressed:checked /template/ Button#PART_PrimaryButton /template/ ContentPresenter, |
|||
SplitButton:pressed:checked /template/ Button#PART_SecondaryButton /template/ ContentPresenter, |
|||
SplitButton:pressed:checked /template/ Border#SeparatorBorder"> |
|||
<Setter Property="Border.Background" Value="{DynamicResource SplitButtonBackgroundCheckedPressed}" /> |
|||
<Setter Property="Border.BorderBrush" Value="{DynamicResource SplitButtonBorderBrushCheckedPressed}" /> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource SplitButtonForegroundCheckedPressed}" /> |
|||
</Style> |
|||
<Style Selector="SplitButton:pressed:checked /template/ Button#PART_SecondaryButton PathIcon"> |
|||
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundCheckedPressed}" /> |
|||
</Style> |
|||
|
|||
<!-- Checked Flyout Open State --> |
|||
<Style Selector="SplitButton:checked:flyout-open /template/ Button#PART_PrimaryButton /template/ ContentPresenter, |
|||
SplitButton:checked:flyout-open /template/ Button#PART_SecondaryButton /template/ ContentPresenter, |
|||
SplitButton:checked:flyout-open /template/ Border#SeparatorBorder"> |
|||
<Setter Property="Border.Background" Value="{DynamicResource SplitButtonBackgroundCheckedPressed}" /> |
|||
<Setter Property="Border.BorderBrush" Value="{DynamicResource SplitButtonBorderBrushCheckedPressed}" /> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource SplitButtonForegroundCheckedPressed}" /> |
|||
</Style> |
|||
<Style Selector="SplitButton:checked:flyout-open /template/ Button#PART_SecondaryButton PathIcon"> |
|||
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundCheckedPressed}" /> |
|||
</Style> |
|||
|
|||
<!-- Disabled Checked State --> |
|||
<Style Selector="SplitButton:checked:disabled /template/ Button#PART_PrimaryButton /template/ ContentPresenter, |
|||
SplitButton:checked:disabled /template/ Button#PART_SecondaryButton /template/ ContentPresenter, |
|||
SplitButton:checked:disabled /template/ Border#SeparatorBorder"> |
|||
<Setter Property="Border.Background" Value="{DynamicResource SplitButtonBackgroundCheckedDisabled}" /> |
|||
<Setter Property="Border.BorderBrush" Value="{DynamicResource SplitButtonBorderBrushCheckedDisabled}" /> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource SplitButtonForegroundCheckedDisabled}" /> |
|||
</Style> |
|||
<Style Selector="SplitButton:checked:disabled /template/ Button#PART_SecondaryButton PathIcon"> |
|||
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundCheckedDisabled}" /> |
|||
</Style> |
|||
</Styles> |
|||
@ -0,0 +1,20 @@ |
|||
<Styles xmlns="https://github.com/avaloniaui" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> |
|||
<Style Selector="TransitioningContentControl"> |
|||
<!-- Set Defaults --> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<ContentPresenter Name="PART_ContentPresenter" |
|||
Background="{TemplateBinding Background}" |
|||
BorderBrush="{TemplateBinding BorderBrush}" |
|||
BorderThickness="{TemplateBinding BorderThickness}" |
|||
CornerRadius="{TemplateBinding CornerRadius}" |
|||
ContentTemplate="{TemplateBinding ContentTemplate}" |
|||
Content="{TemplateBinding CurrentContent}" |
|||
Padding="{TemplateBinding Padding}" |
|||
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" |
|||
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"/> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
</Styles> |
|||
@ -0,0 +1,247 @@ |
|||
<Styles xmlns="https://github.com/avaloniaui" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
x:CompileBindings="True" |
|||
xmlns:converters="using:Avalonia.Controls.Converters"> |
|||
|
|||
<Design.PreviewWith> |
|||
<Border Padding="60"> |
|||
<StackPanel> |
|||
<SplitButton Content="Hello World"> |
|||
<SplitButton.Flyout> |
|||
<Flyout>Hello</Flyout> |
|||
</SplitButton.Flyout> |
|||
</SplitButton> |
|||
<ToggleSplitButton Content="Hello World"> |
|||
<ToggleSplitButton.Flyout> |
|||
<Flyout>Hello</Flyout> |
|||
</ToggleSplitButton.Flyout> |
|||
</ToggleSplitButton> |
|||
</StackPanel> |
|||
</Border> |
|||
</Design.PreviewWith> |
|||
|
|||
<Styles.Resources> |
|||
<x:Double x:Key="SplitButtonPrimaryButtonSize">32</x:Double> |
|||
<x:Double x:Key="SplitButtonSecondaryButtonSize">32</x:Double> |
|||
<x:Double x:Key="SplitButtonSeparatorWidth">1</x:Double> |
|||
|
|||
<converters:MarginMultiplierConverter x:Key="PrimaryButtonBorderMultiplier" Left="True" Top="True" Bottom="True" Indent="1" /> |
|||
<converters:MarginMultiplierConverter x:Key="SecondaryButtonBorderMultiplier" Right="True" Top="True" Bottom="True" Indent="1" /> |
|||
<converters:MarginMultiplierConverter x:Key="SeparatorBorderMultiplier" Top="True" Bottom="True" Indent="1" /> |
|||
</Styles.Resources> |
|||
|
|||
<Style Selector="SplitButton"> |
|||
<Setter Property="Background" Value="{DynamicResource SplitButtonBackground}" /> |
|||
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForeground}" /> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource SplitButtonBorderBrush}" /> |
|||
<Setter Property="BorderThickness" Value="{DynamicResource SplitButtonBorderThemeThickness}" /> |
|||
<Setter Property="HorizontalAlignment" Value="Left" /> |
|||
<Setter Property="VerticalAlignment" Value="Center" /> |
|||
<!--<Setter Property="UseSystemFocusVisuals" Value="True" /> |
|||
<Setter Property="FocusVisualMargin" Value="-3" />--> |
|||
<Setter Property="KeyboardNavigation.IsTabStop" Value="True" /> |
|||
<Setter Property="Focusable" Value="True" /> |
|||
<Setter Property="Padding" Value="{DynamicResource ButtonPadding}" /> |
|||
<Setter Property="CornerRadius" Value="{DynamicResource ControlCornerRadius}" /> |
|||
<Setter Property="Template"> |
|||
<Setter.Value> |
|||
<ControlTemplate> |
|||
<Grid> |
|||
<Grid.ColumnDefinitions> |
|||
<ColumnDefinition Width="*" /> |
|||
<ColumnDefinition Width="Auto" /> |
|||
<ColumnDefinition Width="Auto" /> |
|||
</Grid.ColumnDefinitions> |
|||
|
|||
<Button x:Name="PART_PrimaryButton" |
|||
Grid.Column="0" |
|||
MinWidth="{DynamicResource SplitButtonPrimaryButtonSize}" |
|||
Foreground="{TemplateBinding Foreground}" |
|||
Background="{TemplateBinding Background}" |
|||
BorderThickness="{TemplateBinding BorderThickness, Converter={StaticResource PrimaryButtonBorderMultiplier}}" |
|||
BorderBrush="{TemplateBinding BorderBrush}" |
|||
Content="{TemplateBinding Content}" |
|||
ContentTemplate="{TemplateBinding ContentTemplate}" |
|||
Command="{TemplateBinding Command}" |
|||
CommandParameter="{TemplateBinding CommandParameter}" |
|||
FontFamily="{TemplateBinding FontFamily}" |
|||
FontSize="{TemplateBinding FontSize}" |
|||
FontWeight="{TemplateBinding FontWeight}" |
|||
HorizontalAlignment="Stretch" |
|||
VerticalAlignment="Stretch" |
|||
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" |
|||
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" |
|||
Padding="{TemplateBinding Padding}" |
|||
Focusable="False" |
|||
KeyboardNavigation.IsTabStop="False" /> |
|||
|
|||
<Border x:Name="SeparatorBorder" |
|||
Grid.Column="1" |
|||
Background="Transparent" |
|||
Width="{DynamicResource SplitButtonSeparatorWidth}" |
|||
BorderThickness="{TemplateBinding BorderThickness, Converter={StaticResource SeparatorBorderMultiplier}}" |
|||
BorderBrush="{TemplateBinding BorderBrush}" /> |
|||
|
|||
<Button x:Name="PART_SecondaryButton" |
|||
Grid.Column="2" |
|||
MinWidth="{DynamicResource SplitButtonSecondaryButtonSize}" |
|||
BorderBrush="{TemplateBinding BorderBrush}" |
|||
Foreground="{TemplateBinding Foreground}" |
|||
Background="{TemplateBinding Background}" |
|||
BorderThickness="{TemplateBinding BorderThickness, Converter={StaticResource SecondaryButtonBorderMultiplier}}" |
|||
Padding="0" |
|||
HorizontalContentAlignment="Center" |
|||
VerticalContentAlignment="Center" |
|||
HorizontalAlignment="Stretch" |
|||
VerticalAlignment="Stretch" |
|||
Focusable="False" |
|||
KeyboardNavigation.IsTabStop="False" /> |
|||
</Grid> |
|||
</ControlTemplate> |
|||
</Setter.Value> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
<!-- Default overridable styles --> |
|||
<Style Selector="SplitButton /template/ Button#PART_PrimaryButton"> |
|||
<Setter Property="CornerRadius" Value="{TemplateBinding CornerRadius, Converter={StaticResource LeftCornerRadiusFilterConverter}}" /> |
|||
</Style> |
|||
<Style Selector="SplitButton /template/ Button#PART_SecondaryButton"> |
|||
<Setter Property="CornerRadius" Value="{TemplateBinding CornerRadius, Converter={StaticResource RightCornerRadiusFilterConverter}}" /> |
|||
<Setter Property="Content"> |
|||
<Template> |
|||
<PathIcon Height="12" |
|||
Width="12" |
|||
Data="M1939 486L2029 576L1024 1581L19 576L109 486L1024 1401L1939 486Z" /> |
|||
</Template> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
<!-- Primary and Secondary buttons PointerOver State --> |
|||
<Style Selector="SplitButton /template/ Button#PART_PrimaryButton:pointerover /template/ ContentPresenter, |
|||
SplitButton /template/ Button#PART_SecondaryButton:pointerover /template/ ContentPresenter"> |
|||
<Setter Property="Border.Background" Value="{DynamicResource SplitButtonBackgroundPointerOver}" /> |
|||
<Setter Property="Border.BorderBrush" Value="{DynamicResource SplitButtonBorderBrushPointerOver}" /> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource SplitButtonForegroundPointerOver}" /> |
|||
</Style> |
|||
<Style Selector="SplitButton /template/ Button#PART_SecondaryButton:pointerover PathIcon"> |
|||
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundPointerOver}" /> |
|||
</Style> |
|||
|
|||
<!-- Primary and Secondary buttons Pressed State --> |
|||
<Style Selector="SplitButton /template/ Button#PART_PrimaryButton:pressed /template/ ContentPresenter, |
|||
SplitButton /template/ Button#PART_SecondaryButton:pressed /template/ ContentPresenter"> |
|||
<Setter Property="Border.Background" Value="{DynamicResource SplitButtonBackgroundPressed}" /> |
|||
<Setter Property="Border.BorderBrush" Value="{DynamicResource SplitButtonBorderBrushPressed}" /> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource SplitButtonForegroundPressed}" /> |
|||
</Style> |
|||
<Style Selector="SplitButton /template/ Button#PART_SecondaryButton:pressed PathIcon"> |
|||
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundPressed}" /> |
|||
</Style> |
|||
|
|||
<!-- SplitButton Pressed State --> |
|||
<Style Selector="SplitButton:pressed /template/ Button#PART_PrimaryButton /template/ ContentPresenter, |
|||
SplitButton:pressed /template/ Button#PART_SecondaryButton /template/ ContentPresenter, |
|||
SplitButton:pressed /template/ Border#SeparatorBorder"> |
|||
<Setter Property="Border.Background" Value="{DynamicResource SplitButtonBackgroundPressed}" /> |
|||
<Setter Property="Border.BorderBrush" Value="{DynamicResource SplitButtonBorderBrushPressed}" /> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource SplitButtonForegroundPressed}" /> |
|||
</Style> |
|||
<Style Selector="SplitButton:pressed /template/ Button#PART_SecondaryButton PathIcon"> |
|||
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundPressed}" /> |
|||
</Style> |
|||
|
|||
<!-- Primary and Secondary buttons Flyout Open State --> |
|||
<Style Selector="SplitButton:flyout-open /template/ Button#PART_PrimaryButton /template/ ContentPresenter, |
|||
SplitButton:flyout-open /template/ Button#PART_SecondaryButton /template/ ContentPresenter, |
|||
SplitButton:flyout-open /template/ Border#SeparatorBorder"> |
|||
<Setter Property="Border.Background" Value="{DynamicResource SplitButtonBackgroundPressed}" /> |
|||
<Setter Property="Border.BorderBrush" Value="{DynamicResource SplitButtonBorderBrushPressed}" /> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource SplitButtonForegroundPressed}" /> |
|||
</Style> |
|||
<Style Selector="SplitButton:flyout-open /template/ Button#PART_SecondaryButton PathIcon"> |
|||
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundPressed}" /> |
|||
</Style> |
|||
|
|||
<!-- Disabled State --> |
|||
<Style Selector="SplitButton:disabled /template/ Button#PART_PrimaryButton /template/ ContentPresenter, |
|||
SplitButton:disabled /template/ Button#PART_SecondaryButton /template/ ContentPresenter, |
|||
SplitButton:disabled /template/ Border#SeparatorBorder"> |
|||
<Setter Property="Border.Background" Value="{DynamicResource SplitButtonBackgroundDisabled}" /> |
|||
<Setter Property="Border.BorderBrush" Value="{DynamicResource SplitButtonBorderBrushDisabled}" /> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource SplitButtonForegroundDisabled}" /> |
|||
</Style> |
|||
<Style Selector="SplitButton:disabled /template/ Button#PART_SecondaryButton PathIcon"> |
|||
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundDisabled}" /> |
|||
</Style> |
|||
|
|||
<!-- Checked State --> |
|||
<Style Selector="SplitButton:checked /template/ Button#PART_PrimaryButton /template/ ContentPresenter, |
|||
SplitButton:checked /template/ Button#PART_SecondaryButton /template/ ContentPresenter, |
|||
SplitButton:checked /template/ Border#SeparatorBorder"> |
|||
<Setter Property="Border.Background" Value="{DynamicResource SplitButtonBackgroundChecked}" /> |
|||
<Setter Property="Border.BorderBrush" Value="{DynamicResource SplitButtonBorderBrushChecked}" /> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource SplitButtonForegroundChecked}" /> |
|||
</Style> |
|||
<Style Selector="SplitButton:checked /template/ Button#PART_SecondaryButton PathIcon"> |
|||
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundChecked}" /> |
|||
</Style> |
|||
|
|||
<!-- Checked PointerOver State --> |
|||
<Style Selector="SplitButton:checked /template/ Button#PART_PrimaryButton:pointerover /template/ ContentPresenter, |
|||
SplitButton:checked /template/ Button#PART_SecondaryButton:pointerover /template/ ContentPresenter"> |
|||
<Setter Property="Border.Background" Value="{DynamicResource SplitButtonBackgroundCheckedPointerOver}" /> |
|||
<Setter Property="Border.BorderBrush" Value="{DynamicResource SplitButtonBorderBrushCheckedPointerOver}" /> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource SplitButtonForegroundCheckedPointerOver}" /> |
|||
</Style> |
|||
<Style Selector="SplitButton:checked /template/ Button#PART_SecondaryButton:pointerover PathIcon"> |
|||
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundCheckedPointerOver}" /> |
|||
</Style> |
|||
|
|||
<!-- Checked Pressed State --> |
|||
<Style Selector="SplitButton:checked /template/ Button#PART_PrimaryButton:pressed /template/ ContentPresenter, |
|||
SplitButton:checked /template/ Button#PART_SecondaryButton:pressed /template/ ContentPresenter"> |
|||
<Setter Property="Border.Background" Value="{DynamicResource SplitButtonBackgroundCheckedPressed}" /> |
|||
<Setter Property="Border.BorderBrush" Value="{DynamicResource SplitButtonBorderBrushCheckedPressed}" /> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource SplitButtonForegroundCheckedPressed}" /> |
|||
</Style> |
|||
<Style Selector="SplitButton:checked /template/ Button#PART_SecondaryButton:pressed PathIcon"> |
|||
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundCheckedPressed}" /> |
|||
</Style> |
|||
|
|||
<!-- SplitButton Checked Pressed State --> |
|||
<Style Selector="SplitButton:pressed:checked /template/ Button#PART_PrimaryButton /template/ ContentPresenter, |
|||
SplitButton:pressed:checked /template/ Button#PART_SecondaryButton /template/ ContentPresenter, |
|||
SplitButton:pressed:checked /template/ Border#SeparatorBorder"> |
|||
<Setter Property="Border.Background" Value="{DynamicResource SplitButtonBackgroundCheckedPressed}" /> |
|||
<Setter Property="Border.BorderBrush" Value="{DynamicResource SplitButtonBorderBrushCheckedPressed}" /> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource SplitButtonForegroundCheckedPressed}" /> |
|||
</Style> |
|||
<Style Selector="SplitButton:pressed:checked /template/ Button#PART_SecondaryButton PathIcon"> |
|||
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundCheckedPressed}" /> |
|||
</Style> |
|||
|
|||
<!-- Checked Flyout Open State --> |
|||
<Style Selector="SplitButton:checked:flyout-open /template/ Button#PART_PrimaryButton /template/ ContentPresenter, |
|||
SplitButton:checked:flyout-open /template/ Button#PART_SecondaryButton /template/ ContentPresenter, |
|||
SplitButton:checked:flyout-open /template/ Border#SeparatorBorder"> |
|||
<Setter Property="Border.Background" Value="{DynamicResource SplitButtonBackgroundCheckedPressed}" /> |
|||
<Setter Property="Border.BorderBrush" Value="{DynamicResource SplitButtonBorderBrushCheckedPressed}" /> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource SplitButtonForegroundCheckedPressed}" /> |
|||
</Style> |
|||
<Style Selector="SplitButton:checked:flyout-open /template/ Button#PART_SecondaryButton PathIcon"> |
|||
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundCheckedPressed}" /> |
|||
</Style> |
|||
|
|||
<!-- Disabled Checked State --> |
|||
<Style Selector="SplitButton:checked:disabled /template/ Button#PART_PrimaryButton /template/ ContentPresenter, |
|||
SplitButton:checked:disabled /template/ Button#PART_SecondaryButton /template/ ContentPresenter, |
|||
SplitButton:checked:disabled /template/ Border#SeparatorBorder"> |
|||
<Setter Property="Border.Background" Value="{DynamicResource SplitButtonBackgroundCheckedDisabled}" /> |
|||
<Setter Property="Border.BorderBrush" Value="{DynamicResource SplitButtonBorderBrushCheckedDisabled}" /> |
|||
<Setter Property="TextBlock.Foreground" Value="{DynamicResource SplitButtonForegroundCheckedDisabled}" /> |
|||
</Style> |
|||
<Style Selector="SplitButton:checked:disabled /template/ Button#PART_SecondaryButton PathIcon"> |
|||
<Setter Property="Foreground" Value="{DynamicResource SplitButtonForegroundCheckedDisabled}" /> |
|||
</Style> |
|||
</Styles> |
|||
@ -0,0 +1,20 @@ |
|||
<Styles xmlns="https://github.com/avaloniaui" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> |
|||
<Style Selector="TransitioningContentControl"> |
|||
<!-- Set Defaults --> |
|||
<Setter Property="Template"> |
|||
<ControlTemplate> |
|||
<ContentPresenter Name="PART_ContentPresenter" |
|||
Background="{TemplateBinding Background}" |
|||
BorderBrush="{TemplateBinding BorderBrush}" |
|||
BorderThickness="{TemplateBinding BorderThickness}" |
|||
CornerRadius="{TemplateBinding CornerRadius}" |
|||
ContentTemplate="{TemplateBinding ContentTemplate}" |
|||
Content="{TemplateBinding CurrentContent}" |
|||
Padding="{TemplateBinding Padding}" |
|||
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" |
|||
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"/> |
|||
</ControlTemplate> |
|||
</Setter> |
|||
</Style> |
|||
</Styles> |
|||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue