From 586607a9c246c7cfe07ba58406ded0ce701c48c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wies=C5=82aw=20S=CC=8Colte=CC=81s?= Date: Sat, 13 May 2023 15:21:41 +0200 Subject: [PATCH] Update to preview8 --- build/Avalonia.Desktop.props | 2 +- build/Avalonia.Diagnostics.props | 2 +- build/Avalonia.Fonts.Inter.props | 2 +- build/Avalonia.ReactiveUI.props | 2 +- build/Avalonia.Themes.Fluent.props | 2 +- build/Avalonia.props | 2 +- build/Base.props | 4 ++-- samples/TemplatedDataGridDemo/ViewLocator.cs | 16 ++++++---------- .../Controls/TemplatedListBox.cs | 8 ++++++-- .../Primitives/TemplatedDataGridRowsPresenter.cs | 2 +- 10 files changed, 21 insertions(+), 21 deletions(-) diff --git a/build/Avalonia.Desktop.props b/build/Avalonia.Desktop.props index 35ceb5a..9972da0 100644 --- a/build/Avalonia.Desktop.props +++ b/build/Avalonia.Desktop.props @@ -1,6 +1,6 @@  - + diff --git a/build/Avalonia.Diagnostics.props b/build/Avalonia.Diagnostics.props index a1dd197..8dc0f2c 100644 --- a/build/Avalonia.Diagnostics.props +++ b/build/Avalonia.Diagnostics.props @@ -1,6 +1,6 @@  - + diff --git a/build/Avalonia.Fonts.Inter.props b/build/Avalonia.Fonts.Inter.props index a9bf347..a48077d 100644 --- a/build/Avalonia.Fonts.Inter.props +++ b/build/Avalonia.Fonts.Inter.props @@ -1,6 +1,6 @@  - + diff --git a/build/Avalonia.ReactiveUI.props b/build/Avalonia.ReactiveUI.props index 6625b9d..ff2b5f3 100644 --- a/build/Avalonia.ReactiveUI.props +++ b/build/Avalonia.ReactiveUI.props @@ -1,6 +1,6 @@  - + diff --git a/build/Avalonia.Themes.Fluent.props b/build/Avalonia.Themes.Fluent.props index 205803c..cbe48c3 100644 --- a/build/Avalonia.Themes.Fluent.props +++ b/build/Avalonia.Themes.Fluent.props @@ -1,6 +1,6 @@  - + diff --git a/build/Avalonia.props b/build/Avalonia.props index cde92f3..ae5a0f9 100644 --- a/build/Avalonia.props +++ b/build/Avalonia.props @@ -1,6 +1,6 @@  - + diff --git a/build/Base.props b/build/Base.props index f509e18..1c7cf66 100644 --- a/build/Base.props +++ b/build/Base.props @@ -1,10 +1,10 @@ 11.0.0 - preview6 + preview8 Wiesław Šoltés Wiesław Šoltés - Copyright © Wiesław Šoltés 2021 + Copyright © Wiesław Šoltés 2023 MIT https://github.com/wieslawsoltes/TemplatedDataGrid diff --git a/samples/TemplatedDataGridDemo/ViewLocator.cs b/samples/TemplatedDataGridDemo/ViewLocator.cs index a750c20..1543f3e 100644 --- a/samples/TemplatedDataGridDemo/ViewLocator.cs +++ b/samples/TemplatedDataGridDemo/ViewLocator.cs @@ -7,24 +7,20 @@ namespace TemplatedDataGridDemo { public class ViewLocator : IDataTemplate { - public bool SupportsRecycling => false; - - public Control Build(object data) + public Control Build(object? data) { - var name = data.GetType().FullName!.Replace("ViewModel", "View"); - var type = Type.GetType(name); + var name = data?.GetType().FullName?.Replace("ViewModel", "View"); + var type = name is null ? null : Type.GetType(name); if (type != null) { return (Control)Activator.CreateInstance(type)!; } - else - { - return new TextBlock { Text = "Not Found: " + name }; - } + + return new TextBlock { Text = "Not Found: " + name }; } - public bool Match(object data) + public bool Match(object? data) { return data is ViewModelBase; } diff --git a/src/TemplatedDataGrid/Controls/TemplatedListBox.cs b/src/TemplatedDataGrid/Controls/TemplatedListBox.cs index 633d4dc..cd7ed80 100644 --- a/src/TemplatedDataGrid/Controls/TemplatedListBox.cs +++ b/src/TemplatedDataGrid/Controls/TemplatedListBox.cs @@ -1,6 +1,5 @@ using System; using Avalonia.Controls; -using Avalonia.Controls.Generators; using Avalonia.Styling; namespace TemplatedDataGrid.Controls @@ -9,9 +8,14 @@ namespace TemplatedDataGrid.Controls { Type IStyleable.StyleKey => typeof(ListBox); - protected override Control CreateContainerForItemOverride() + protected override Control CreateContainerForItemOverride(object? item, int index, object? recycleKey) { return new TemplatedListBoxItem(); } + + protected override bool NeedsContainerOverride(object? item, int index, out object? recycleKey) + { + return NeedsContainer(item, out recycleKey); + } } } diff --git a/src/TemplatedDataGrid/Primitives/TemplatedDataGridRowsPresenter.cs b/src/TemplatedDataGrid/Primitives/TemplatedDataGridRowsPresenter.cs index bea8d46..10e83d1 100644 --- a/src/TemplatedDataGrid/Primitives/TemplatedDataGridRowsPresenter.cs +++ b/src/TemplatedDataGrid/Primitives/TemplatedDataGridRowsPresenter.cs @@ -133,7 +133,7 @@ namespace TemplatedDataGrid.Primitives { var listBoxDisposables = new CompositeDisposable(); - _listBox.OneWayBind(ItemsControl.ItemsProperty, this, ItemsProperty, listBoxDisposables); + _listBox.OneWayBind(ItemsControl.ItemsSourceProperty, this, ItemsProperty, listBoxDisposables); _listBox.OneWayBind(SelectingItemsControl.AutoScrollToSelectedItemProperty, this, AutoScrollToSelectedItemProperty, listBoxDisposables); _listBox.OneWayBind(ItemsControl.ItemTemplateProperty, this, ItemTemplateProperty, listBoxDisposables);