Browse Source

Merge branch 'master' into fixes/textIssues

pull/11034/head
Benedikt Stebner 4 years ago
committed by GitHub
parent
commit
7892817c4a
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 42
      Avalonia.sln
  2. 4
      samples/ControlCatalog/Pages/AutoCompleteBoxPage.xaml.cs
  3. 2
      samples/ControlCatalog/Pages/ContextFlyoutPage.xaml
  4. 2
      samples/ControlCatalog/Pages/DataGridPage.xaml
  5. 4
      samples/ControlCatalog/Pages/DataGridPage.xaml.cs
  6. 4
      samples/ControlCatalog/Pages/DialogsPage.xaml
  7. 2
      samples/ControlCatalog/Pages/ItemsRepeaterPage.xaml
  8. BIN
      samples/SafeAreaDemo.Android/Icon.png
  9. 11
      samples/SafeAreaDemo.Android/MainActivity.cs
  10. 5
      samples/SafeAreaDemo.Android/Properties/AndroidManifest.xml
  11. 13
      samples/SafeAreaDemo.Android/Resources/drawable/splash_screen.xml
  12. 4
      samples/SafeAreaDemo.Android/Resources/values/colors.xml
  13. 17
      samples/SafeAreaDemo.Android/Resources/values/styles.xml
  14. 24
      samples/SafeAreaDemo.Android/SafeAreaDemo.Android.csproj
  15. 30
      samples/SafeAreaDemo.Android/SplashActivity.cs
  16. 21
      samples/SafeAreaDemo.Desktop/Program.cs
  17. 24
      samples/SafeAreaDemo.Desktop/SafeAreaDemo.Desktop.csproj
  18. 18
      samples/SafeAreaDemo.Desktop/app.manifest
  19. 17
      samples/SafeAreaDemo.iOS/AppDelegate.cs
  20. 5
      samples/SafeAreaDemo.iOS/Entitlements.plist
  21. 47
      samples/SafeAreaDemo.iOS/Info.plist
  22. 15
      samples/SafeAreaDemo.iOS/Main.cs
  23. 43
      samples/SafeAreaDemo.iOS/Resources/LaunchScreen.xib
  24. 18
      samples/SafeAreaDemo.iOS/SafeAreaDemo.iOS.csproj
  25. 15
      samples/SafeAreaDemo/App.xaml
  26. 36
      samples/SafeAreaDemo/App.xaml.cs
  27. BIN
      samples/SafeAreaDemo/Assets/avalonia-logo.ico
  28. 27
      samples/SafeAreaDemo/SafeAreaDemo.csproj
  29. 31
      samples/SafeAreaDemo/ViewLocator.cs
  30. 112
      samples/SafeAreaDemo/ViewModels/MainViewModel.cs
  31. 52
      samples/SafeAreaDemo/Views/MainView.xaml
  32. 25
      samples/SafeAreaDemo/Views/MainView.xaml.cs
  33. 12
      samples/SafeAreaDemo/Views/MainWindow.xaml
  34. 13
      samples/SafeAreaDemo/Views/MainWindow.xaml.cs
  35. 6
      src/Avalonia.Base/Media/Effects/DropShadowEffect.cs
  36. 4
      src/Avalonia.Base/Media/Effects/IDropShadowEffect.cs
  37. 27
      src/Avalonia.Controls.DataGrid/DataGrid.cs
  38. 2
      src/Avalonia.Controls.DataGrid/DataGridBoundColumn.cs
  39. 4
      src/Avalonia.Controls.DataGrid/DataGridDataConnection.cs
  40. 4
      src/Avalonia.Controls.DataGrid/DataGridTemplateColumn.cs
  41. 22
      src/Avalonia.Controls.ItemsRepeater/Controls/ItemsRepeater.cs
  42. 36
      src/Avalonia.Controls/AutoCompleteBox/AutoCompleteBox.Properties.cs
  43. 26
      src/Avalonia.Controls/AutoCompleteBox/AutoCompleteBox.cs
  44. 34
      src/Avalonia.Controls/Flyouts/MenuFlyout.cs
  45. 2
      src/Avalonia.Controls/ItemsSourceView.cs
  46. 4
      src/Avalonia.Controls/RadioButton.cs
  47. 2
      src/Avalonia.Controls/Utils/ISelectionAdapter.cs
  48. 2
      src/Avalonia.Controls/Utils/SelectingItemsControlSelectionAdapter.cs
  49. 2
      src/Avalonia.Diagnostics/Diagnostics/Views/ControlDetailsView.xaml
  50. 8
      src/Avalonia.Themes.Fluent/Controls/TextBox.xaml
  51. 9
      src/Avalonia.Themes.Simple/Controls/TextBox.xaml
  52. 35
      src/Avalonia.X11/X11Window.cs
  53. 3
      src/Avalonia.X11/XI2Manager.cs
  54. 3
      src/Avalonia.X11/XLib.cs
  55. 8
      tests/Avalonia.Controls.ItemsRepeater.UnitTests/ItemsRepeaterTests.cs
  56. 10
      tests/Avalonia.Controls.UnitTests/AutoCompleteBoxTests.cs
  57. 2
      tests/Avalonia.Controls.UnitTests/MaskedTextBoxTests.cs
  58. 2
      tests/Avalonia.Controls.UnitTests/MenuItemTests.cs
  59. 2
      tests/Avalonia.Controls.UnitTests/TextBoxTests.cs
  60. 2
      tests/Avalonia.LeakTests/ControlTests.cs
  61. 2
      tests/Avalonia.Markup.Xaml.UnitTests/Xaml/StyleTests.cs

42
Avalonia.sln

@ -244,13 +244,21 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.Controls.ItemsRepe
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.Controls.ItemsRepeater.UnitTests", "tests\Avalonia.Controls.ItemsRepeater.UnitTests\Avalonia.Controls.ItemsRepeater.UnitTests.csproj", "{F4E36AA8-814E-4704-BC07-291F70F45193}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Avalonia.Generators", "src\tools\Avalonia.Generators\Avalonia.Generators.csproj", "{DDA28789-C21A-4654-86CE-D01E81F095C5}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.Generators", "src\tools\Avalonia.Generators\Avalonia.Generators.csproj", "{DDA28789-C21A-4654-86CE-D01E81F095C5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Avalonia.Generators.Tests", "tests\Avalonia.Generators.Tests\Avalonia.Generators.Tests.csproj", "{2D7C812B-7E73-4252-8EFD-BC8A4D5CCB9F}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.Generators.Tests", "tests\Avalonia.Generators.Tests\Avalonia.Generators.Tests.csproj", "{2D7C812B-7E73-4252-8EFD-BC8A4D5CCB9F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Avalonia.Fonts.Inter", "src\Avalonia.Fonts.Inter\Avalonia.Fonts.Inter.csproj", "{13F1135D-BA1A-435C-9C5B-A368D1D63DE4}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.Fonts.Inter", "src\Avalonia.Fonts.Inter\Avalonia.Fonts.Inter.csproj", "{13F1135D-BA1A-435C-9C5B-A368D1D63DE4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Generators.Sandbox", "samples\Generators.Sandbox\Generators.Sandbox.csproj", "{A82AD1BC-EBE6-4FC3-A13B-D52A50297533}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Generators.Sandbox", "samples\Generators.Sandbox\Generators.Sandbox.csproj", "{A82AD1BC-EBE6-4FC3-A13B-D52A50297533}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SafeAreaDemo", "samples\SafeAreaDemo\SafeAreaDemo.csproj", "{6B60A970-D5D2-49C2-8BAB-F9C7973B74B6}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SafeAreaDemo.Android", "samples\SafeAreaDemo.Android\SafeAreaDemo.Android.csproj", "{22E3BC08-EAF7-4889-BDC4-B4D3046C4E2D}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SafeAreaDemo.Desktop", "samples\SafeAreaDemo.Desktop\SafeAreaDemo.Desktop.csproj", "{4CDAD037-34A2-4CCF-A03A-C6C7B988A572}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SafeAreaDemo.iOS", "samples\SafeAreaDemo.iOS\SafeAreaDemo.iOS.csproj", "{FC956F9A-4C3A-4A1A-ACDD-BB54DCB661DD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -595,6 +603,26 @@ Global
{A82AD1BC-EBE6-4FC3-A13B-D52A50297533}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A82AD1BC-EBE6-4FC3-A13B-D52A50297533}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A82AD1BC-EBE6-4FC3-A13B-D52A50297533}.Release|Any CPU.Build.0 = Release|Any CPU
{6B60A970-D5D2-49C2-8BAB-F9C7973B74B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6B60A970-D5D2-49C2-8BAB-F9C7973B74B6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6B60A970-D5D2-49C2-8BAB-F9C7973B74B6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6B60A970-D5D2-49C2-8BAB-F9C7973B74B6}.Release|Any CPU.Build.0 = Release|Any CPU
{22E3BC08-EAF7-4889-BDC4-B4D3046C4E2D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{22E3BC08-EAF7-4889-BDC4-B4D3046C4E2D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{22E3BC08-EAF7-4889-BDC4-B4D3046C4E2D}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{22E3BC08-EAF7-4889-BDC4-B4D3046C4E2D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{22E3BC08-EAF7-4889-BDC4-B4D3046C4E2D}.Release|Any CPU.Build.0 = Release|Any CPU
{22E3BC08-EAF7-4889-BDC4-B4D3046C4E2D}.Release|Any CPU.Deploy.0 = Release|Any CPU
{4CDAD037-34A2-4CCF-A03A-C6C7B988A572}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4CDAD037-34A2-4CCF-A03A-C6C7B988A572}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4CDAD037-34A2-4CCF-A03A-C6C7B988A572}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4CDAD037-34A2-4CCF-A03A-C6C7B988A572}.Release|Any CPU.Build.0 = Release|Any CPU
{FC956F9A-4C3A-4A1A-ACDD-BB54DCB661DD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FC956F9A-4C3A-4A1A-ACDD-BB54DCB661DD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FC956F9A-4C3A-4A1A-ACDD-BB54DCB661DD}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{FC956F9A-4C3A-4A1A-ACDD-BB54DCB661DD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FC956F9A-4C3A-4A1A-ACDD-BB54DCB661DD}.Release|Any CPU.Build.0 = Release|Any CPU
{FC956F9A-4C3A-4A1A-ACDD-BB54DCB661DD}.Release|Any CPU.Deploy.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -661,10 +689,14 @@ Global
{75C47156-C5D8-44BC-A5A7-E8657C2248D6} = {9B9E3891-2366-4253-A952-D08BCEB71098}
{C810060E-3809-4B74-A125-F11533AF9C1B} = {9B9E3891-2366-4253-A952-D08BCEB71098}
{C692FE73-43DB-49CE-87FC-F03ED61F25C9} = {4ED8B739-6F4E-4CD4-B993-545E6B5CE637}
{F4E36AA8-814E-4704-BC07-291F70F45193} = {C5A00AC3-B34C-4564-9BDD-2DA473EF4D8B}
{DDA28789-C21A-4654-86CE-D01E81F095C5} = {4ED8B739-6F4E-4CD4-B993-545E6B5CE637}
{2D7C812B-7E73-4252-8EFD-BC8A4D5CCB9F} = {C5A00AC3-B34C-4564-9BDD-2DA473EF4D8B}
{F4E36AA8-814E-4704-BC07-291F70F45193} = {C5A00AC3-B34C-4564-9BDD-2DA473EF4D8B}
{A82AD1BC-EBE6-4FC3-A13B-D52A50297533} = {9B9E3891-2366-4253-A952-D08BCEB71098}
{6B60A970-D5D2-49C2-8BAB-F9C7973B74B6} = {9B9E3891-2366-4253-A952-D08BCEB71098}
{22E3BC08-EAF7-4889-BDC4-B4D3046C4E2D} = {9B9E3891-2366-4253-A952-D08BCEB71098}
{4CDAD037-34A2-4CCF-A03A-C6C7B988A572} = {9B9E3891-2366-4253-A952-D08BCEB71098}
{FC956F9A-4C3A-4A1A-ACDD-BB54DCB661DD} = {9B9E3891-2366-4253-A952-D08BCEB71098}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {87366D66-1391-4D90-8999-95A620AD786A}

4
samples/ControlCatalog/Pages/AutoCompleteBoxPage.xaml.cs

@ -114,7 +114,7 @@ namespace ControlCatalog.Pages
foreach (AutoCompleteBox box in GetAllAutoCompleteBox().Where(x => x.Name != "CustomAutocompleteBox"))
{
box.Items = States;
box.ItemsSource = States;
}
var converter = new FuncMultiValueConverter<string, string>(parts =>
@ -132,7 +132,7 @@ namespace ControlCatalog.Pages
asyncBox.AsyncPopulator = PopulateAsync;
var customAutocompleteBox = this.Get<AutoCompleteBox>("CustomAutocompleteBox");
customAutocompleteBox.Items = Sentences.SelectMany(x => x);
customAutocompleteBox.ItemsSource = Sentences.SelectMany(x => x);
customAutocompleteBox.TextFilter = LastWordContains;
customAutocompleteBox.TextSelector = AppendWord;
}

2
samples/ControlCatalog/Pages/ContextFlyoutPage.xaml

@ -67,7 +67,7 @@
</Style>
</Border.Styles>
<Border.ContextFlyout>
<MenuFlyout Items="{Binding MenuItems}" />
<MenuFlyout ItemsSource="{Binding MenuItems}" />
</Border.ContextFlyout>
<TextBlock Text="Dynamically Generated"/>
</Border>

2
samples/ControlCatalog/Pages/DataGridPage.xaml

@ -94,7 +94,7 @@
<Grid RowDefinitions="*,Auto">
<!-- Example of columns inheriting the data type from the Items source -->
<DataGrid Name="dataGridEdit" Margin="12" Grid.Row="0"
Items="{Binding DataGrid3Source}">
ItemsSource="{Binding DataGrid3Source}">
<DataGrid.Columns>
<DataGridTextColumn Header="First Name" Binding="{Binding FirstName}" Width="2*" FontSize="{Binding #FontSizeSlider.Value, Mode=OneWay}" />
<DataGridTextColumn Header="Last" Binding="{Binding LastName}" Width="2*" FontSize="{Binding #FontSizeSlider.Value, Mode=OneWay}" />

4
samples/ControlCatalog/Pages/DataGridPage.xaml.cs

@ -36,7 +36,7 @@ namespace ControlCatalog.Pages
collectionView1.SortDescriptions.Add(dataGridSortDescription);
}
};
dg1.Items = collectionView1;
dg1.ItemsSource = collectionView1;
var dg2 = this.Get<DataGrid>("dataGridGrouping");
dg2.IsReadOnly = true;
@ -44,7 +44,7 @@ namespace ControlCatalog.Pages
var collectionView2 = new DataGridCollectionView(Countries.All);
collectionView2.GroupDescriptions.Add(new DataGridPathGroupDescription("Region"));
dg2.Items = collectionView2;
dg2.ItemsSource = collectionView2;
var dg3 = this.Get<DataGrid>("dataGridEdit");
dg3.IsReadOnly = false;

4
samples/ControlCatalog/Pages/DialogsPage.xaml

@ -45,7 +45,7 @@
</Expander>
<AutoCompleteBox x:Name="CurrentFolderBox" Watermark="Write full path/uri or well known folder name">
<AutoCompleteBox.Items>
<AutoCompleteBox.ItemsSource>
<generic:List x:TypeArguments="storage:WellKnownFolder">
<storage:WellKnownFolder>Desktop</storage:WellKnownFolder>
<storage:WellKnownFolder>Documents</storage:WellKnownFolder>
@ -54,7 +54,7 @@
<storage:WellKnownFolder>Videos</storage:WellKnownFolder>
<storage:WellKnownFolder>Music</storage:WellKnownFolder>
</generic:List>
</AutoCompleteBox.Items>
</AutoCompleteBox.ItemsSource>
</AutoCompleteBox>
<TextBlock x:Name="PickerLastResultsVisible"

2
samples/ControlCatalog/Pages/ItemsRepeaterPage.xaml

@ -66,7 +66,7 @@
<ScrollViewer Name="scroller"
HorizontalScrollBarVisibility="Auto"
VerticalScrollBarVisibility="Auto">
<ItemsRepeater Name="repeater" Background="Transparent" Items="{Binding Items}"
<ItemsRepeater Name="repeater" Background="Transparent" ItemsSource="{Binding Items}"
ItemTemplate="{StaticResource elementFactory}"/>
</ScrollViewer>
</Border>

BIN
samples/SafeAreaDemo.Android/Icon.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

11
samples/SafeAreaDemo.Android/MainActivity.cs

@ -0,0 +1,11 @@
using Android.App;
using Android.Content.PM;
using Avalonia.Android;
namespace SafeAreaDemo.Android
{
[Activity(Label = "SafeAreaDemo.Android", Theme = "@style/MyTheme.NoActionBar", Icon = "@drawable/icon", LaunchMode = LaunchMode.SingleTop, ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.ScreenSize | ConfigChanges.UiMode)]
public class MainActivity : AvaloniaMainActivity
{
}
}

5
samples/SafeAreaDemo.Android/Properties/AndroidManifest.xml

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto">
<uses-permission android:name="android.permission.INTERNET" />
<application android:label="SafeAreaDemo" android:icon="@drawable/Icon" />
</manifest>

13
samples/SafeAreaDemo.Android/Resources/drawable/splash_screen.xml

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<color android:color="@color/splash_background"/>
</item>
<item android:drawable="@drawable/icon"
android:width="120dp"
android:height="120dp"
android:gravity="center" />
</layer-list>

4
samples/SafeAreaDemo.Android/Resources/values/colors.xml

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="splash_background">#FFFFFF</color>
</resources>

17
samples/SafeAreaDemo.Android/Resources/values/styles.xml

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8" ?>
<resources>
<style name="MyTheme">
</style>
<style name="MyTheme.NoActionBar" parent="@style/Theme.AppCompat.NoActionBar">
<item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
</style>
<style name="MyTheme.Splash" parent ="MyTheme.NoActionBar">
<item name="android:windowBackground">@drawable/splash_screen</item>
<item name="android:windowContentOverlay">@null</item>
</style>
</resources>

24
samples/SafeAreaDemo.Android/SafeAreaDemo.Android.csproj

@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0-android</TargetFramework>
<SupportedOSPlatformVersion>21</SupportedOSPlatformVersion>
<Nullable>enable</Nullable>
<ApplicationId>com.avalonia.safeareademo</ApplicationId>
<ApplicationVersion>1</ApplicationVersion>
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<AndroidPackageFormat>apk</AndroidPackageFormat>
<AndroidEnableProfiledAot>False</AndroidEnableProfiledAot>
</PropertyGroup>
<ItemGroup>
<AndroidResource Include="Icon.png">
<Link>Resources\drawable\Icon.png</Link>
</AndroidResource>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SafeAreaDemo\SafeAreaDemo.csproj" />
<ProjectReference Include="..\..\src\Android\Avalonia.Android\Avalonia.Android.csproj" />
</ItemGroup>
</Project>

30
samples/SafeAreaDemo.Android/SplashActivity.cs

@ -0,0 +1,30 @@
using Android.App;
using Android.Content;
using Android.OS;
using Avalonia;
using Avalonia.Android;
using Application = Android.App.Application;
namespace SafeAreaDemo.Android
{
[Activity(Theme = "@style/MyTheme.Splash", MainLauncher = true, NoHistory = true)]
public class SplashActivity : AvaloniaSplashActivity<App>
{
protected override AppBuilder CustomizeAppBuilder(AppBuilder builder)
{
return base.CustomizeAppBuilder(builder);
}
protected override void OnCreate(Bundle? savedInstanceState)
{
base.OnCreate(savedInstanceState);
}
protected override void OnResume()
{
base.OnResume();
StartActivity(new Intent(Application.Context, typeof(MainActivity)));
}
}
}

21
samples/SafeAreaDemo.Desktop/Program.cs

@ -0,0 +1,21 @@
using Avalonia;
using System;
namespace SafeAreaDemo.Desktop
{
internal class Program
{
// Initialization code. Don't use any Avalonia, third-party APIs or any
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
// yet and stuff might break.
[STAThread]
public static void Main(string[] args) => BuildAvaloniaApp()
.StartWithClassicDesktopLifetime(args);
// Avalonia configuration, don't remove; also used by visual designer.
public static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure<App>()
.UsePlatformDetect()
.LogToTrace();
}
}

24
samples/SafeAreaDemo.Desktop/SafeAreaDemo.Desktop.csproj

@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<!--If you are willing to use Windows/MacOS native APIs you will need to create 3 projects.
One for Windows with net7.0-windows TFM, one for MacOS with net7.0-macos and one with net7.0 TFM for Linux.-->
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Avalonia.Diagnostics\Avalonia.Diagnostics.csproj" />
<ProjectReference Include="..\..\src\Avalonia.Headless.Vnc\Avalonia.Headless.Vnc.csproj" />
<ProjectReference Include="..\..\src\Linux\Avalonia.LinuxFramebuffer\Avalonia.LinuxFramebuffer.csproj" />
<ProjectReference Include="..\..\src\Avalonia.X11\Avalonia.X11.csproj" />
<ProjectReference Include="..\SafeAreaDemo\SafeAreaDemo.csproj" />
</ItemGroup>
<Import Project="..\..\build\SampleApp.props" />
<Import Project="..\..\build\ReferenceCoreLibraries.props" />
</Project>

18
samples/SafeAreaDemo.Desktop/app.manifest

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<!-- This manifest is used on Windows only.
Don't remove it as it might cause problems with window transparency and embeded controls.
For more details visit https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests -->
<assemblyIdentity version="1.0.0.0" name="SafeAreaDemo.Desktop"/>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- A list of the Windows versions that this application has been tested on
and is designed to work with. Uncomment the appropriate elements
and Windows will automatically select the most compatible environment. -->
<!-- Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
</application>
</compatibility>
</assembly>

17
samples/SafeAreaDemo.iOS/AppDelegate.cs

@ -0,0 +1,17 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.iOS;
using Avalonia.Media;
using Foundation;
using UIKit;
namespace SafeAreaDemo.iOS
{
// The UIApplicationDelegate for the application. This class is responsible for launching the
// User Interface of the application, as well as listening (and optionally responding) to
// application events from iOS.
[Register("AppDelegate")]
public partial class AppDelegate : AvaloniaAppDelegate<App>
{
}
}

5
samples/SafeAreaDemo.iOS/Entitlements.plist

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict/>
</plist>

47
samples/SafeAreaDemo.iOS/Info.plist

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDisplayName</key>
<string>SafeAreaDemo</string>
<key>CFBundleIdentifier</key>
<string>companyName.SafeAreaDemo</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>MinimumOSVersion</key>
<string>10.0</string>
<key>UIDeviceFamily</key>
<array>
<integer>1</integer>
<integer>2</integer>
</array>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIStatusBarHidden</key>
<true/>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
</dict>
</plist>

15
samples/SafeAreaDemo.iOS/Main.cs

@ -0,0 +1,15 @@
using UIKit;
namespace SafeAreaDemo.iOS
{
public class Application
{
// This is the main entry point of the application.
static void Main(string[] args)
{
// if you want to use a different Application Delegate class from "AppDelegate"
// you can specify it here.
UIApplication.Main(args, null, typeof(AppDelegate));
}
}
}

43
samples/SafeAreaDemo.iOS/Resources/LaunchScreen.xib

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6214" systemVersion="14A314h" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6207" />
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1" />
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" />
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder" />
<view contentMode="scaleToFill" id="iN0-l3-epB">
<rect key="frame" x="0.0" y="0.0" width="480" height="480" />
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES" />
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text=" Copyright (c) 2022 " textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines"
minimumFontSize="9" translatesAutoresizingMaskIntoConstraints="NO" id="8ie-xW-0ye">
<rect key="frame" x="20" y="439" width="441" height="21" />
<fontDescription key="fontDescription" type="system" pointSize="17" />
<color key="textColor" cocoaTouchSystemColor="darkTextColor" />
<nil key="highlightedColor" />
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="SafeAreaDemo" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines"
minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="kId-c2-rCX">
<rect key="frame" x="20" y="140" width="441" height="43" />
<fontDescription key="fontDescription" type="boldSystem" pointSize="36" />
<color key="textColor" cocoaTouchSystemColor="darkTextColor" />
<nil key="highlightedColor" />
</label>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite" />
<constraints>
<constraint firstItem="kId-c2-rCX" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="bottom" multiplier="1/3" constant="1" id="5cJ-9S-tgC" />
<constraint firstAttribute="centerX" secondItem="kId-c2-rCX" secondAttribute="centerX" id="Koa-jz-hwk" />
<constraint firstAttribute="bottom" secondItem="8ie-xW-0ye" secondAttribute="bottom" constant="20" id="Kzo-t9-V3l" />
<constraint firstItem="8ie-xW-0ye" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="20" symbolic="YES" id="MfP-vx-nX0" />
<constraint firstAttribute="centerX" secondItem="8ie-xW-0ye" secondAttribute="centerX" id="ZEH-qu-HZ9" />
<constraint firstItem="kId-c2-rCX" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="20" symbolic="YES" id="fvb-Df-36g" />
</constraints>
<nil key="simulatedStatusBarMetrics" />
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics" />
<point key="canvasLocation" x="548" y="455" />
</view>
</objects>
</document>

18
samples/SafeAreaDemo.iOS/SafeAreaDemo.iOS.csproj

@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0-ios</TargetFramework>
<SupportedOSPlatformVersion>10.0</SupportedOSPlatformVersion>
<ProvisioningType>manual</ProvisioningType>
<Nullable>enable</Nullable>
<RuntimeIdentifier>iossimulator-x64</RuntimeIdentifier>
<!-- These properties need to be set in order to run on a real iDevice -->
<!--<RuntimeIdentifier>ios-arm64</RuntimeIdentifier>-->
<!--<CodesignKey></CodesignKey>-->
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\SafeAreaDemo\SafeAreaDemo.csproj" />
<ProjectReference Include="..\..\src\iOS\Avalonia.iOS\Avalonia.iOS.csproj" />
</ItemGroup>
</Project>

15
samples/SafeAreaDemo/App.xaml

@ -0,0 +1,15 @@
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:SafeAreaDemo"
x:Class="SafeAreaDemo.App"
RequestedThemeVariant="Default">
<!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. -->
<Application.DataTemplates>
<local:ViewLocator/>
</Application.DataTemplates>
<Application.Styles>
<FluentTheme />
</Application.Styles>
</Application>

36
samples/SafeAreaDemo/App.xaml.cs

@ -0,0 +1,36 @@
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
using SafeAreaDemo.ViewModels;
using SafeAreaDemo.Views;
namespace SafeAreaDemo
{
public partial class App : Application
{
public override void Initialize()
{
AvaloniaXamlLoader.Load(this);
}
public override void OnFrameworkInitializationCompleted()
{
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
desktop.MainWindow = new MainWindow
{
DataContext = new MainViewModel()
};
}
else if (ApplicationLifetime is ISingleViewApplicationLifetime singleViewPlatform)
{
singleViewPlatform.MainView = new MainView
{
DataContext = new MainViewModel()
};
}
base.OnFrameworkInitializationCompleted();
}
}
}

BIN
samples/SafeAreaDemo/Assets/avalonia-logo.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 172 KiB

27
samples/SafeAreaDemo/SafeAreaDemo.csproj

@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
</PropertyGroup>
<ItemGroup>
<Compile Update="**\*.xaml.cs">
<DependentUpon>%(Filename)</DependentUpon>
</Compile>
<AvaloniaResource Include="**\*.xaml">
<SubType>Designer</SubType>
</AvaloniaResource>
<AvaloniaResource Include="Assets\**" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\packages\Avalonia\Avalonia.csproj" />
<ProjectReference Include="..\..\src\Avalonia.Themes.Fluent\Avalonia.Themes.Fluent.csproj" />
<ProjectReference Include="..\MiniMvvm\MiniMvvm.csproj" />
</ItemGroup>
<Import Project="..\..\build\BuildTargets.targets" />
</Project>

31
samples/SafeAreaDemo/ViewLocator.cs

@ -0,0 +1,31 @@
using System;
using Avalonia.Controls;
using Avalonia.Controls.Templates;
using MiniMvvm;
namespace SafeAreaDemo
{
public class ViewLocator : IDataTemplate
{
public Control? Build(object? data)
{
if (data is null)
return null;
var name = data.GetType().FullName!.Replace("ViewModel", "View");
var type = Type.GetType(name);
if (type != null)
{
return (Control)Activator.CreateInstance(type)!;
}
return new TextBlock { Text = name };
}
public bool Match(object? data)
{
return data is ViewModelBase;
}
}
}

112
samples/SafeAreaDemo/ViewModels/MainViewModel.cs

@ -0,0 +1,112 @@
using Avalonia;
using Avalonia.Controls.Platform;
using MiniMvvm;
namespace SafeAreaDemo.ViewModels
{
public class MainViewModel : ViewModelBase
{
private bool _useSafeArea = true;
private bool _fullscreen;
private IInsetsManager? _insetsManager;
private bool _hideSystemBars;
public Thickness SafeAreaPadding
{
get
{
return _insetsManager?.SafeAreaPadding ?? default;
}
}
public Thickness ViewPadding
{
get
{
return _useSafeArea ? SafeAreaPadding : default;
}
}
public bool UseSafeArea
{
get => _useSafeArea;
set
{
_useSafeArea = value;
this.RaisePropertyChanged();
RaiseSafeAreaChanged();
}
}
public bool Fullscreen
{
get => _fullscreen;
set
{
_fullscreen = value;
if (_insetsManager != null)
{
_insetsManager.DisplayEdgeToEdge = value;
}
this.RaisePropertyChanged();
RaiseSafeAreaChanged();
}
}
public bool HideSystemBars
{
get => _hideSystemBars;
set
{
_hideSystemBars = value;
if (_insetsManager != null)
{
_insetsManager.IsSystemBarVisible = !value;
}
this.RaisePropertyChanged();
RaiseSafeAreaChanged();
}
}
internal IInsetsManager? InsetsManager
{
get => _insetsManager;
set
{
if (_insetsManager != null)
{
_insetsManager.SafeAreaChanged -= InsetsManager_SafeAreaChanged;
}
_insetsManager = value;
if (_insetsManager != null)
{
_insetsManager.SafeAreaChanged += InsetsManager_SafeAreaChanged;
_insetsManager.DisplayEdgeToEdge = _fullscreen;
_insetsManager.IsSystemBarVisible = !_hideSystemBars;
}
}
}
private void InsetsManager_SafeAreaChanged(object? sender, SafeAreaChangedArgs e)
{
RaiseSafeAreaChanged();
}
private void RaiseSafeAreaChanged()
{
this.RaisePropertyChanged(nameof(SafeAreaPadding));
this.RaisePropertyChanged(nameof(ViewPadding));
}
}
}

52
samples/SafeAreaDemo/Views/MainView.xaml

@ -0,0 +1,52 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:SafeAreaDemo.ViewModels"
mc:Ignorable="d"
d:DesignWidth="800"
d:DesignHeight="450"
x:Class="SafeAreaDemo.Views.MainView"
x:DataType="vm:MainViewModel">
<Grid HorizontalAlignment="Stretch"
VerticalAlignment="Stretch">
<Border BorderBrush="Red"
Margin="{Binding ViewPadding}"
BorderThickness="1">
<Grid>
<Label Margin="5"
Foreground="Red"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Right">View Bounds</Label>
<Label Margin="5"
Foreground="Red"
VerticalAlignment="Bottom"
HorizontalContentAlignment="Right">View Bounds</Label>
</Grid>
</Border>
<Border BorderBrush="LimeGreen"
Margin="{Binding SafeAreaPadding}"
BorderThickness="1">
<DockPanel>
<Label Margin="5"
Foreground="LimeGreen"
DockPanel.Dock="Bottom"
HorizontalAlignment="Stretch"
HorizontalContentAlignment="Left" >Safe Area</Label>
<Grid DockPanel.Dock="Bottom"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch">
<StackPanel Orientation="Vertical"
HorizontalAlignment="Center"
VerticalAlignment="Center">
<Label HorizontalAlignment="Left">Options:</Label>
<CheckBox IsChecked="{Binding Fullscreen}">Fullscreen</CheckBox>
<CheckBox IsChecked="{Binding UseSafeArea}">Use Safe Area</CheckBox>
<CheckBox IsChecked="{Binding HideSystemBars}">Hide System Bars</CheckBox>
<TextBox Width="200" Watermark="Tap to Show Keyboard"/>
</StackPanel>
</Grid>
</DockPanel>
</Border>
</Grid>
</UserControl>

25
samples/SafeAreaDemo/Views/MainView.xaml.cs

@ -0,0 +1,25 @@
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using SafeAreaDemo.ViewModels;
namespace SafeAreaDemo.Views
{
public partial class MainView : UserControl
{
public MainView()
{
AvaloniaXamlLoader.Load(this);
}
protected override void OnLoaded()
{
base.OnLoaded();
var insetsManager = TopLevel.GetTopLevel(this)?.InsetsManager;
if (insetsManager != null && DataContext is MainViewModel viewModel)
{
viewModel.InsetsManager = insetsManager;
}
}
}
}

12
samples/SafeAreaDemo/Views/MainWindow.xaml

@ -0,0 +1,12 @@
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="using:SafeAreaDemo.ViewModels"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:views="clr-namespace:SafeAreaDemo.Views"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="SafeAreaDemo.Views.MainWindow"
Icon="/Assets/avalonia-logo.ico"
Title="SafeAreaDemo">
<views:MainView />
</Window>

13
samples/SafeAreaDemo/Views/MainWindow.xaml.cs

@ -0,0 +1,13 @@
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
namespace SafeAreaDemo.Views
{
public partial class MainWindow : Window
{
public MainWindow()
{
AvaloniaXamlLoader.Load(this);
}
}
}

6
src/Avalonia.Base/Media/Effects/DropShadowEffect.cs

@ -18,7 +18,7 @@ public abstract class DropShadowEffectBase : Effect
}
public static readonly StyledProperty<Color> ColorProperty = AvaloniaProperty.Register<DropShadowEffectBase, Color>(
nameof(Color));
nameof(Color), Colors.Black);
public Color Color
{
@ -97,8 +97,8 @@ public class DropShadowDirectionEffect : DropShadowEffectBase, IDirectionDropSha
set => SetValue(DirectionProperty, value);
}
public double OffsetX => Math.Cos(Direction) * ShadowDepth;
public double OffsetY => Math.Sin(Direction) * ShadowDepth;
public double OffsetX => Math.Cos(Direction * Math.PI / 180) * ShadowDepth;
public double OffsetY => Math.Sin(Direction * Math.PI / 180) * ShadowDepth;
public IImmutableEffect ToImmutable() => new ImmutableDropShadowDirectionEffect(OffsetX, OffsetY, BlurRadius, Color, Opacity);
}

4
src/Avalonia.Base/Media/Effects/IDropShadowEffect.cs

@ -67,8 +67,8 @@ public class ImmutableDropShadowDirectionEffect : IDirectionDropShadowEffect, II
Opacity = opacity;
}
public double OffsetX => Math.Cos(Direction) * ShadowDepth;
public double OffsetY => Math.Sin(Direction) * ShadowDepth;
public double OffsetX => Math.Cos(Direction * Math.PI / 180) * ShadowDepth;
public double OffsetY => Math.Sin(Direction * Math.PI / 180) * ShadowDepth;
public double Direction { get; }
public double ShadowDepth { get; }
public double BlurRadius { get; }

27
src/Avalonia.Controls.DataGrid/DataGrid.cs

@ -152,8 +152,6 @@ namespace Avalonia.Controls
private double _verticalOffset;
private byte _verticalScrollChangesIgnored;
private IEnumerable _items;
public event EventHandler<ScrollEventArgs> HorizontalScroll;
public event EventHandler<ScrollEventArgs> VerticalScroll;
@ -652,21 +650,18 @@ namespace Avalonia.Controls
}
/// <summary>
/// Identifies the ItemsSource dependency property.
/// Identifies the ItemsSource property.
/// </summary>
public static readonly DirectProperty<DataGrid, IEnumerable> ItemsProperty =
AvaloniaProperty.RegisterDirect<DataGrid, IEnumerable>(
nameof(Items),
o => o.Items,
(o, v) => o.Items = v);
public static readonly StyledProperty<IEnumerable> ItemsSourceProperty =
AvaloniaProperty.Register<DataGrid, IEnumerable>(nameof(ItemsSource));
/// <summary>
/// Gets or sets a collection that is used to generate the content of the control.
/// </summary>
public IEnumerable Items
public IEnumerable ItemsSource
{
get { return _items; }
set { SetAndRaise(ItemsProperty, ref _items, value); }
get => GetValue(ItemsSourceProperty);
set => SetValue(ItemsSourceProperty, value);
}
public static readonly StyledProperty<bool> AreRowDetailsFrozenProperty =
@ -713,7 +708,7 @@ namespace Avalonia.Controls
HorizontalScrollBarVisibilityProperty,
VerticalScrollBarVisibilityProperty);
ItemsProperty.Changed.AddClassHandler<DataGrid>((x, e) => x.OnItemsPropertyChanged(e));
ItemsSourceProperty.Changed.AddClassHandler<DataGrid>((x, e) => x.OnItemsSourcePropertyChanged(e));
CanUserResizeColumnsProperty.Changed.AddClassHandler<DataGrid>((x, e) => x.OnCanUserResizeColumnsChanged(e));
ColumnWidthProperty.Changed.AddClassHandler<DataGrid>((x, e) => x.OnColumnWidthChanged(e));
FrozenColumnCountProperty.Changed.AddClassHandler<DataGrid>((x, e) => x.OnFrozenColumnCountChanged(e));
@ -816,10 +811,10 @@ namespace Avalonia.Controls
}
/// <summary>
/// ItemsProperty property changed handler.
/// ItemsSourceProperty property changed handler.
/// </summary>
/// <param name="e">The event arguments.</param>
private void OnItemsPropertyChanged(AvaloniaPropertyChangedEventArgs e)
private void OnItemsSourcePropertyChanged(AvaloniaPropertyChangedEventArgs e)
{
if (!_areHandlersSuspended)
{
@ -830,7 +825,7 @@ namespace Avalonia.Controls
if (LoadingOrUnloadingRow)
{
SetValueNoCallback(ItemsProperty, oldValue);
SetValueNoCallback(ItemsSourceProperty, oldValue);
throw DataGridError.DataGrid.CannotChangeItemsWhenLoadingRows();
}
@ -1855,7 +1850,7 @@ namespace Avalonia.Controls
{
get
{
if (CurrentSlot == -1 || Items == null || RowGroupHeadersTable.Contains(CurrentSlot))
if (CurrentSlot == -1 || ItemsSource == null || RowGroupHeadersTable.Contains(CurrentSlot))
{
return null;
}

2
src/Avalonia.Controls.DataGrid/DataGridBoundColumn.cs

@ -25,7 +25,7 @@ namespace Avalonia.Controls
/// </summary>
//TODO Binding
[AssignBinding]
[InheritDataTypeFromItems(nameof(DataGrid.Items), AncestorType = typeof(DataGrid))]
[InheritDataTypeFromItems(nameof(DataGrid.ItemsSource), AncestorType = typeof(DataGrid))]
public virtual IBinding Binding
{
get

4
src/Avalonia.Controls.DataGrid/DataGridDataConnection.cs

@ -122,9 +122,9 @@ namespace Avalonia.Controls
// We need to use the raw ItemsSource as opposed to DataSource because DataSource
// may be the ItemsSource wrapped in a collection view, in which case we wouldn't
// be able to take T to be the type if we're given IEnumerable<T>
if (_dataType == null && _owner.Items != null)
if (_dataType == null && _owner.ItemsSource != null)
{
_dataType = _owner.Items.GetItemType();
_dataType = _owner.ItemsSource.GetItemType();
}
return _dataType;
}

4
src/Avalonia.Controls.DataGrid/DataGridTemplateColumn.cs

@ -24,7 +24,7 @@ namespace Avalonia.Controls
(o, v) => o.CellTemplate = v);
[Content]
[InheritDataTypeFromItems(nameof(DataGrid.Items), AncestorType = typeof(DataGrid))]
[InheritDataTypeFromItems(nameof(DataGrid.ItemsSource), AncestorType = typeof(DataGrid))]
public IDataTemplate CellTemplate
{
get { return _cellTemplate; }
@ -51,7 +51,7 @@ namespace Avalonia.Controls
/// <remarks>
/// If this property is <see langword="null"/> the column is read-only.
/// </remarks>
[InheritDataTypeFromItems(nameof(DataGrid.Items), AncestorType = typeof(DataGrid))]
[InheritDataTypeFromItems(nameof(DataGrid.ItemsSource), AncestorType = typeof(DataGrid))]
public IDataTemplate CellEditingTemplate
{
get => _cellEditingCellTemplate;

22
src/Avalonia.Controls.ItemsRepeater/Controls/ItemsRepeater.cs

@ -36,13 +36,13 @@ namespace Avalonia.Controls
ItemsControl.ItemTemplateProperty.AddOwner<ItemsRepeater>();
/// <summary>
/// Defines the <see cref="Items"/> property.
/// Defines the <see cref="ItemsSource"/> property.
/// </summary>
public static readonly DirectProperty<ItemsRepeater, IEnumerable?> ItemsProperty =
public static readonly DirectProperty<ItemsRepeater, IEnumerable?> ItemsSourceProperty =
AvaloniaProperty.RegisterDirect<ItemsRepeater, IEnumerable?>(
nameof(Items),
o => o.Items,
(o, v) => o.Items = v);
nameof(ItemsSource),
o => o.ItemsSource,
(o, v) => o.ItemsSource = v);
/// <summary>
/// Defines the <see cref="Layout"/> property.
@ -65,7 +65,7 @@ namespace Avalonia.Controls
private readonly ViewManager _viewManager;
private readonly ViewportManager _viewportManager;
private readonly TargetWeakEventSubscriber<ItemsRepeater, EventArgs> _layoutWeakSubscriber;
private IEnumerable? _items;
private IEnumerable? _itemsSource;
private RepeaterLayoutContext? _layoutContext;
private EventHandler<ChildIndexChangedEventArgs>? _childIndexChanged;
private bool _isLayoutInProgress;
@ -116,16 +116,16 @@ namespace Avalonia.Controls
/// <summary>
/// Gets or sets an object source used to generate the content of the ItemsRepeater.
/// </summary>
public IEnumerable? Items
public IEnumerable? ItemsSource
{
get => _items;
set => SetAndRaise(ItemsProperty, ref _items, value);
get => _itemsSource;
set => SetAndRaise(ItemsSourceProperty, ref _itemsSource, value);
}
/// <summary>
/// Gets or sets the template used to display each item.
/// </summary>
[InheritDataTypeFromItems(nameof(Items))]
[InheritDataTypeFromItems(nameof(ItemsSource))]
public IDataTemplate? ItemTemplate
{
get => GetValue(ItemTemplateProperty);
@ -415,7 +415,7 @@ namespace Avalonia.Controls
/// <inheritdoc />
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
{
if (change.Property == ItemsProperty)
if (change.Property == ItemsSourceProperty)
{
var (oldEnumerable, newEnumerable) = change.GetOldAndNewValue<IEnumerable?>();

36
src/Avalonia.Controls/AutoCompleteBox/AutoCompleteBox.Properties.cs

@ -143,12 +143,12 @@ namespace Avalonia.Controls
nameof(TextSelector));
/// <summary>
/// Identifies the <see cref="Items" /> property.
/// Identifies the <see cref="ItemsSource" /> property.
/// </summary>
/// <value>The identifier for the <see cref="Items" /> property.</value>
public static readonly StyledProperty<IEnumerable?> ItemsProperty =
/// <value>The identifier for the <see cref="ItemsSource" /> property.</value>
public static readonly StyledProperty<IEnumerable?> ItemsSourceProperty =
AvaloniaProperty.Register<AutoCompleteBox, IEnumerable?>(
nameof(Items));
nameof(ItemsSource));
/// <summary>
/// Identifies the <see cref="AsyncPopulator" /> property.
@ -311,10 +311,10 @@ namespace Avalonia.Controls
/// <summary>
/// Gets the text that is used to filter items in the
/// <see cref="Items" /> item collection.
/// <see cref="ItemsSource" /> item collection.
/// </summary>
/// <value>The text that is used to filter items in the
/// <see cref="Items" /> item collection.</value>
/// <see cref="ItemsSource" /> item collection.</value>
/// <remarks>
/// The SearchText value is typically the same as the
/// Text property, but is set after the TextChanged event occurs
@ -339,7 +339,7 @@ namespace Avalonia.Controls
/// <summary>
/// Gets or sets how the text in the text box is used to filter items
/// specified by the <see cref="Items" />
/// specified by the <see cref="ItemsSource" />
/// property for display in the drop-down.
/// </summary>
/// <value>One of the <see cref="AutoCompleteFilterMode" />
@ -366,11 +366,11 @@ namespace Avalonia.Controls
/// <summary>
/// Gets or sets the custom method that uses user-entered text to filter
/// the items specified by the <see cref="Items" />
/// the items specified by the <see cref="ItemsSource" />
/// property for display in the drop-down.
/// </summary>
/// <value>The custom method that uses the user-entered text to filter
/// the items specified by the <see cref="Items" />
/// the items specified by the <see cref="ItemsSource" />
/// property. The default is null.</value>
/// <remarks>
/// The filter mode is automatically set to Custom if you set the
@ -384,11 +384,11 @@ namespace Avalonia.Controls
/// <summary>
/// Gets or sets the custom method that uses the user-entered text to
/// filter items specified by the <see cref="Items" />
/// filter items specified by the <see cref="ItemsSource" />
/// property in a text-based way for display in the drop-down.
/// </summary>
/// <value>The custom method that uses the user-entered text to filter
/// items specified by the <see cref="Items" />
/// items specified by the <see cref="ItemsSource" />
/// property in a text-based way for display in the drop-down.</value>
/// <remarks>
/// The search mode is automatically set to Custom if you set the
@ -402,11 +402,11 @@ namespace Avalonia.Controls
/// <summary>
/// Gets or sets the custom method that combines the user-entered
/// text and one of the items specified by the <see cref="Items" />.
/// text and one of the items specified by the <see cref="ItemsSource" />.
/// </summary>
/// <value>
/// The custom method that combines the user-entered
/// text and one of the items specified by the <see cref="Items" />.
/// text and one of the items specified by the <see cref="ItemsSource" />.
/// </value>
public AutoCompleteSelector<object>? ItemSelector
{
@ -417,11 +417,11 @@ namespace Avalonia.Controls
/// <summary>
/// Gets or sets the custom method that combines the user-entered
/// text and one of the items specified by the
/// <see cref="Items" /> in a text-based way.
/// <see cref="ItemsSource" /> in a text-based way.
/// </summary>
/// <value>
/// The custom method that combines the user-entered
/// text and one of the items specified by the <see cref="Items" />
/// text and one of the items specified by the <see cref="ItemsSource" />
/// in a text-based way.
/// </value>
public AutoCompleteSelector<string?>? TextSelector
@ -442,10 +442,10 @@ namespace Avalonia.Controls
/// </summary>
/// <value>The collection that is used to generate the items of the
/// drop-down portion of the <see cref="AutoCompleteBox" /> control.</value>
public IEnumerable? Items
public IEnumerable? ItemsSource
{
get => GetValue(ItemsProperty);
set => SetValue(ItemsProperty, value);
get => GetValue(ItemsSourceProperty);
set => SetValue(ItemsSourceProperty, value);
}
}
}

26
src/Avalonia.Controls/AutoCompleteBox/AutoCompleteBox.cs

@ -419,9 +419,9 @@ namespace Avalonia.Controls
/// ItemsSourceProperty property changed handler.
/// </summary>
/// <param name="e">Event arguments.</param>
private void OnItemsPropertyChanged(AvaloniaPropertyChangedEventArgs e)
private void OnItemsSourcePropertyChanged(AvaloniaPropertyChangedEventArgs e)
{
OnItemsChanged((IEnumerable?)e.NewValue);
OnItemsSourceChanged((IEnumerable?)e.NewValue);
}
private void OnItemTemplatePropertyChanged(AvaloniaPropertyChangedEventArgs e)
@ -461,7 +461,7 @@ namespace Avalonia.Controls
SearchTextProperty.Changed.AddClassHandler<AutoCompleteBox>((x,e) => x.OnSearchTextPropertyChanged(e));
FilterModeProperty.Changed.AddClassHandler<AutoCompleteBox>((x,e) => x.OnFilterModePropertyChanged(e));
ItemFilterProperty.Changed.AddClassHandler<AutoCompleteBox>((x,e) => x.OnItemFilterPropertyChanged(e));
ItemsProperty.Changed.AddClassHandler<AutoCompleteBox>((x,e) => x.OnItemsPropertyChanged(e));
ItemsSourceProperty.Changed.AddClassHandler<AutoCompleteBox>((x,e) => x.OnItemsSourcePropertyChanged(e));
ItemTemplateProperty.Changed.AddClassHandler<AutoCompleteBox>((x,e) => x.OnItemTemplatePropertyChanged(e));
IsEnabledProperty.Changed.AddClassHandler<AutoCompleteBox>((x,e) => x.OnControlIsEnabledChanged(e));
}
@ -559,7 +559,7 @@ namespace Avalonia.Controls
_adapter.Commit -= OnAdapterSelectionComplete;
_adapter.Cancel -= OnAdapterSelectionCanceled;
_adapter.Cancel -= OnAdapterSelectionComplete;
_adapter.Items = null;
_adapter.ItemsSource = null;
}
_adapter = value;
@ -570,7 +570,7 @@ namespace Avalonia.Controls
_adapter.Commit += OnAdapterSelectionComplete;
_adapter.Cancel += OnAdapterSelectionCanceled;
_adapter.Cancel += OnAdapterSelectionComplete;
_adapter.Items = _view;
_adapter.ItemsSource = _view;
}
}
}
@ -1128,7 +1128,7 @@ namespace Avalonia.Controls
{
if (!cancellationToken.IsCancellationRequested)
{
SetCurrentValue(ItemsProperty, resultList);
SetCurrentValue(ItemsSourceProperty, resultList);
PopulateComplete();
}
});
@ -1475,7 +1475,7 @@ namespace Avalonia.Controls
/// adapter's ItemsSource to the view if appropriate.
/// </summary>
/// <param name="newValue">The new enumerable reference.</param>
private void OnItemsChanged(IEnumerable? newValue)
private void OnItemsSourceChanged(IEnumerable? newValue)
{
// Remove handler for oldValue.CollectionChanged (if present)
_collectionChangeSubscription?.Dispose();
@ -1492,9 +1492,9 @@ namespace Avalonia.Controls
// Clear and set the view on the selection adapter
ClearView();
if (SelectionAdapter != null && SelectionAdapter.Items != _view)
if (SelectionAdapter != null && SelectionAdapter.ItemsSource != _view)
{
SelectionAdapter.Items = _view;
SelectionAdapter.ItemsSource = _view;
}
if (IsDropDownOpen)
{
@ -1545,9 +1545,9 @@ namespace Avalonia.Controls
{
// Significant changes to the underlying data.
ClearView();
if (Items != null)
if (ItemsSource != null)
{
_items = new List<object>(Items.Cast<object>());
_items = new List<object>(ItemsSource.Cast<object>());
}
}
@ -1582,9 +1582,9 @@ namespace Avalonia.Controls
PopulatedEventArgs populated = new PopulatedEventArgs(new ReadOnlyCollection<object>(_view!));
OnPopulated(populated);
if (SelectionAdapter != null && SelectionAdapter.Items != _view)
if (SelectionAdapter != null && SelectionAdapter.ItemsSource != _view)
{
SelectionAdapter.Items = _view;
SelectionAdapter.ItemsSource = _view;
}
bool isDropDownOpen = _userCalledPopulate && (_view!.Count > 0);

34
src/Avalonia.Controls/Flyouts/MenuFlyout.cs

@ -1,6 +1,5 @@
using System.Collections;
using System.ComponentModel;
using Avalonia.Collections;
using Avalonia.Controls.Primitives;
using Avalonia.Controls.Templates;
using Avalonia.Metadata;
@ -12,17 +11,15 @@ namespace Avalonia.Controls
{
public MenuFlyout()
{
_items = new AvaloniaList<object>();
Items = new ItemCollection();
}
/// <summary>
/// Defines the <see cref="Items"/> property
/// Defines the <see cref="ItemsSource"/> property
/// </summary>
public static readonly DirectProperty<MenuFlyout, IEnumerable?> ItemsProperty =
AvaloniaProperty.RegisterDirect<MenuFlyout, IEnumerable?>(
nameof(Items),
x => x.Items,
(x, v) => x.Items = v);
public static readonly StyledProperty<IEnumerable?> ItemsSourceProperty =
AvaloniaProperty.Register<MenuFlyout, IEnumerable?>(
nameof(ItemsSource));
/// <summary>
/// Defines the <see cref="ItemTemplate"/> property
@ -45,14 +42,16 @@ namespace Avalonia.Controls
public Classes FlyoutPresenterClasses => _classes ??= new Classes();
[Content]
public ItemCollection Items { get; }
/// <summary>
/// Gets or sets the items of the MenuFlyout
/// </summary>
[Content]
public IEnumerable? Items
public IEnumerable? ItemsSource
{
get => _items;
set => SetAndRaise(ItemsProperty, ref _items, value);
get => GetValue(ItemsSourceProperty);
set => SetValue(ItemsSourceProperty, value);
}
/// <summary>
@ -83,14 +82,13 @@ namespace Avalonia.Controls
}
private Classes? _classes;
private IEnumerable? _items;
private IDataTemplate? _itemTemplate;
protected override Control CreatePresenter()
{
return new MenuFlyoutPresenter
{
[!ItemsControl.ItemsSourceProperty] = this[!ItemsProperty],
ItemsSource = Items,
[!ItemsControl.ItemTemplateProperty] = this[!ItemTemplateProperty],
[!ItemsControl.ItemContainerThemeProperty] = this[!ItemContainerThemeProperty],
};
@ -113,5 +111,13 @@ namespace Avalonia.Controls
base.OnOpening(args);
}
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
{
base.OnPropertyChanged(change);
if (change.Property == ItemsSourceProperty)
Items.SetItemsSource(change.GetNewValue<IEnumerable?>());
}
}
}

2
src/Avalonia.Controls/ItemsSourceView.cs

@ -262,7 +262,7 @@ namespace Avalonia.Controls
_source = source switch
{
ItemsSourceView => throw new ArgumentException("Cannot wrap an existing ItemsSourceView.", nameof(source)),
ItemsSourceView isv => isv.Source,
IList list => list,
INotifyCollectionChanged => throw new ArgumentException(
"Collection implements INotifyCollectionChanged but not IList.",

4
src/Avalonia.Controls/RadioButton.cs

@ -86,7 +86,7 @@ namespace Avalonia.Controls
continue;
}
if (current != radioButton && current.IsChecked.GetValueOrDefault())
current.IsChecked = false;
current.SetCurrentValue(IsCheckedProperty, false);
i++;
}
if (group.Count == 0)
@ -193,7 +193,7 @@ namespace Avalonia.Controls
foreach (var sibling in siblings)
{
if (sibling.IsChecked.GetValueOrDefault())
sibling.IsChecked = false;
sibling.SetCurrentValue(IsCheckedProperty, false);
}
}
}

2
src/Avalonia.Controls/Utils/ISelectionAdapter.cs

@ -36,7 +36,7 @@ namespace Avalonia.Controls.Utils
/// </summary>
/// <value>The collection that is used to generate content for the
/// selection adapter.</value>
IEnumerable? Items { get; set; }
IEnumerable? ItemsSource { get; set; }
/// <summary>
/// Occurs when a selected item is not cancelled and is committed as the

2
src/Avalonia.Controls/Utils/SelectingItemsControlSelectionAdapter.cs

@ -140,7 +140,7 @@ namespace Avalonia.Controls.Utils
/// </summary>
/// <value>The collection used to generate content for the selection
/// adapter.</value>
public IEnumerable? Items
public IEnumerable? ItemsSource
{
get
{

2
src/Avalonia.Diagnostics/Diagnostics/Views/ControlDetailsView.xaml

@ -51,7 +51,7 @@
<DataGrid
x:Name="DataGrid"
Items="{Binding PropertiesView}"
ItemsSource="{Binding PropertiesView}"
Grid.Row="2"
BorderThickness="0"
RowBackground="Transparent"

8
src/Avalonia.Themes.Fluent/Controls/TextBox.xaml

@ -1,4 +1,4 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Design.PreviewWith>
<Border Padding="20">
@ -26,12 +26,6 @@
<MenuItem x:Name="TextBoxContextFlyoutPasteItem" Header="Paste" Command="{Binding $parent[TextBox].Paste}" IsEnabled="{Binding $parent[TextBox].CanPaste}" InputGesture="{x:Static TextBox.PasteGesture}"/>
</MenuFlyout>
<ContextMenu x:Key="DefaultTextBoxContextMenu" x:Name="TextBoxContextMenu">
<MenuItem x:Name="TextBoxContextMenuCutItem" Header="Cut" Command="{Binding $parent[TextBox].Cut}" IsEnabled="{Binding $parent[TextBox].CanCut}" InputGesture="{x:Static TextBox.CutGesture}" />
<MenuItem x:Name="TextBoxContextMenuCopyItem" Header="Copy" Command="{Binding $parent[TextBox].Copy}" IsEnabled="{Binding $parent[TextBox].CanCopy}" InputGesture="{x:Static TextBox.CopyGesture}"/>
<MenuItem x:Name="TextBoxContextMenuPasteItem" Header="Paste" Command="{Binding $parent[TextBox].Paste}" IsEnabled="{Binding $parent[TextBox].CanPaste}" InputGesture="{x:Static TextBox.PasteGesture}"/>
</ContextMenu>
<ControlTheme x:Key="FluentTextBoxButton" TargetType="Button">
<Setter Property="Background" Value="{DynamicResource TextControlButtonBackground}" />
<Setter Property="BorderBrush" Value="{DynamicResource TextControlButtonBorderBrush}" />

9
src/Avalonia.Themes.Simple/Controls/TextBox.xaml

@ -13,15 +13,6 @@
IsEnabled="{Binding $parent[TextBox].CanPaste}" InputGesture="{x:Static TextBox.PasteGesture}" />
</MenuFlyout>
<ContextMenu x:Key="SimpleTextBoxContextMenu" x:Name="TextBoxContextMenu">
<MenuItem x:Name="TextBoxContextMenuCutItem" Header="Cut" Command="{Binding $parent[TextBox].Cut}"
IsEnabled="{Binding $parent[TextBox].CanCut}" InputGesture="{x:Static TextBox.CutGesture}" />
<MenuItem x:Name="TextBoxContextMenuCopyItem" Header="Copy" Command="{Binding $parent[TextBox].Copy}"
IsEnabled="{Binding $parent[TextBox].CanCopy}" InputGesture="{x:Static TextBox.CopyGesture}" />
<MenuItem x:Name="TextBoxContextMenuPasteItem" Header="Paste" Command="{Binding $parent[TextBox].Paste}"
IsEnabled="{Binding $parent[TextBox].CanPaste}" InputGesture="{x:Static TextBox.PasteGesture}" />
</ContextMenu>
<ControlTheme x:Key="SimpleTextBoxClearButtonTheme"
BasedOn="{StaticResource {x:Type Button}}"
TargetType="Button">

35
src/Avalonia.X11/X11Window.cs

@ -24,6 +24,7 @@ using Avalonia.X11.Glx;
using Avalonia.X11.NativeDialogs;
using static Avalonia.X11.XLib;
using Avalonia.Input.Platform;
using System.Runtime.InteropServices;
// ReSharper disable IdentifierTypo
// ReSharper disable StringLiteralTypo
@ -629,6 +630,8 @@ namespace Avalonia.X11
ChangeWMAtoms(false, _x11.Atoms._NET_WM_STATE_FULLSCREEN);
ChangeWMAtoms(false, _x11.Atoms._NET_WM_STATE_MAXIMIZED_VERT,
_x11.Atoms._NET_WM_STATE_MAXIMIZED_HORZ);
SendNetWMMessage(_x11.Atoms._NET_ACTIVE_WINDOW, (IntPtr)1, _x11.LastActivityTimestamp,
IntPtr.Zero);
}
}
}
@ -735,6 +738,10 @@ namespace Avalonia.X11
{
if (_inputRoot is null)
return;
if (_disabled && args is RawPointerEventArgs pargs && pargs.Type == RawPointerEventType.Move)
return;
Input?.Invoke(args);
if (!args.Handled && args is RawKeyEventArgsWithText text && !string.IsNullOrEmpty(text.Text))
Input?.Invoke(new RawTextInputEventArgs(_keyboard, args.Timestamp, _inputRoot, text.Text));
@ -1201,6 +1208,32 @@ namespace Avalonia.X11
public void SetEnabled(bool enable)
{
_disabled = !enable;
UpdateWMHints();
}
private void UpdateWMHints()
{
var wmHintsPtr = XGetWMHints(_x11.Display, _handle);
XWMHints hints = default;
if (wmHintsPtr != IntPtr.Zero)
{
hints = Marshal.PtrToStructure<XWMHints>(wmHintsPtr);
}
var flags = hints.flags.ToInt64();
flags |= (long)XWMHintsFlags.InputHint;
hints.flags = (IntPtr)flags;
hints.input = !_disabled ? 1 : 0;
XSetWMHints(_x11.Display, _handle, ref hints);
if (wmHintsPtr != IntPtr.Zero)
{
XFree(wmHintsPtr);
}
}
public void SetExtendClientAreaToDecorationsHint(bool extendIntoClientAreaHint)
@ -1290,6 +1323,8 @@ namespace Avalonia.X11
public bool NeedsManagedDecorations => false;
public bool IsEnabled => !_disabled;
public class SurfacePlatformHandle : IPlatformNativeSurfaceHandle
{
private readonly X11Window _owner;

3
src/Avalonia.X11/XI2Manager.cs

@ -231,7 +231,7 @@ namespace Avalonia.X11
return;
}
if (_multitouch && ev.Emulated)
if (!client.IsEnabled || (_multitouch && ev.Emulated))
return;
if (ev.Type == XiEventType.XI_Motion)
@ -370,6 +370,7 @@ namespace Avalonia.X11
internal interface IXI2Client
{
bool IsEnabled { get; }
IInputRoot InputRoot { get; }
void ScheduleXI2Input(RawInputEventArgs args);
IMouseDevice MouseDevice { get; }

3
src/Avalonia.X11/XLib.cs

@ -375,6 +375,9 @@ namespace Avalonia.X11
[DllImport(libX11)]
public static extern void XSetWMHints(IntPtr display, IntPtr window, ref XWMHints wmhints);
[DllImport(libX11)]
public static extern IntPtr XGetWMHints(IntPtr display, IntPtr window);
[DllImport(libX11)]
public static extern int XGetIconSizes(IntPtr display, IntPtr window, out IntPtr size_list, out int count);

8
tests/Avalonia.Controls.ItemsRepeater.UnitTests/ItemsRepeaterTests.cs

@ -9,16 +9,16 @@ namespace Avalonia.Controls.UnitTests
public void Can_Reassign_Items()
{
var target = new ItemsRepeater();
target.Items = new ObservableCollection<string>();
target.Items = new ObservableCollection<string>();
target.ItemsSource = new ObservableCollection<string>();
target.ItemsSource = new ObservableCollection<string>();
}
[Fact]
public void Can_Reassign_Items_To_Null()
{
var target = new ItemsRepeater();
target.Items = new ObservableCollection<string>();
target.Items = null;
target.ItemsSource = new ObservableCollection<string>();
target.ItemsSource = null;
}
}
}

10
tests/Avalonia.Controls.UnitTests/AutoCompleteBoxTests.cs

@ -89,7 +89,7 @@ namespace Avalonia.Controls.UnitTests
bool closeEvent = false;
control.DropDownOpened += (s, e) => openEvent = true;
control.DropDownClosed += (s, e) => closeEvent = true;
control.Items = CreateSimpleStringArray();
control.ItemsSource = CreateSimpleStringArray();
textbox.Text = "a";
Dispatcher.UIThread.RunJobs();
@ -258,7 +258,7 @@ namespace Avalonia.Controls.UnitTests
control.FilterMode = AutoCompleteFilterMode.None;
control.Populating += (s, e) =>
{
control.Items = new string[] { custom };
control.ItemsSource = new string[] { custom };
Assert.Equal(search, e.Parameter);
};
control.Populated += (s, e) =>
@ -380,7 +380,7 @@ namespace Avalonia.Controls.UnitTests
{
RunTest((control, textbox) =>
{
object selectedItem = control.Items.Cast<object>().First();
object selectedItem = control.ItemsSource.Cast<object>().First();
string input = "42";
control.TextSelector = (text, item) => text + item;
@ -397,7 +397,7 @@ namespace Avalonia.Controls.UnitTests
{
RunTest((control, textbox) =>
{
object selectedItem = control.Items.Cast<object>().First();
object selectedItem = control.ItemsSource.Cast<object>().First();
string input = "42";
control.ItemSelector = (text, item) => text + item;
@ -1053,7 +1053,7 @@ namespace Avalonia.Controls.UnitTests
using (UnitTestApplication.Start(Services))
{
AutoCompleteBox control = CreateControl();
control.Items = CreateSimpleStringArray();
control.ItemsSource = CreateSimpleStringArray();
TextBox textBox = GetTextBox(control);
var window = new Window {Content = control};
window.ApplyStyling();

2
tests/Avalonia.Controls.UnitTests/MaskedTextBoxTests.cs

@ -72,7 +72,7 @@ namespace Avalonia.Controls.UnitTests
Text = "1234",
ContextFlyout = new MenuFlyout
{
Items = new List<MenuItem>
Items =
{
new MenuItem { Header = "Item 1" },
new MenuItem {Header = "Item 2" },

2
tests/Avalonia.Controls.UnitTests/MenuItemTests.cs

@ -232,7 +232,7 @@ namespace Avalonia.Controls.UnitTests
return true;
});
var target = new MenuItem();
var flyout = new MenuFlyout { Items = new AvaloniaList<MenuItem> { target } };
var flyout = new MenuFlyout { Items = { target } };
var button = new Button { Flyout = flyout };
var window = new Window { Content = button };
window.ApplyStyling();

2
tests/Avalonia.Controls.UnitTests/TextBoxTests.cs

@ -93,7 +93,7 @@ namespace Avalonia.Controls.UnitTests
Text = "1234",
ContextFlyout = new MenuFlyout
{
Items = new List<MenuItem>
Items =
{
new MenuItem { Header = "Item 1" },
new MenuItem {Header = "Item 2" },

2
tests/Avalonia.LeakTests/ControlTests.cs

@ -51,7 +51,7 @@ namespace Avalonia.LeakTests
{
Content = new DataGrid
{
Items = _observableCollection
ItemsSource = _observableCollection
}
};

2
tests/Avalonia.Markup.Xaml.UnitTests/Xaml/StyleTests.cs

@ -424,7 +424,7 @@ namespace Avalonia.Markup.Xaml.UnitTests.Xaml
};
var list = window.FindControl<ItemsRepeater>("list");
list.Items = collection;
list.ItemsSource = collection;
window.Show();

Loading…
Cancel
Save