This commit is contained in:
Wiesław Šoltés 2023-05-13 15:21:41 +02:00
Родитель 7a7be22329
Коммит 586607a9c2
10 изменённых файлов: 21 добавлений и 21 удалений

Просмотреть файл

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<PackageReference Include="Avalonia.Desktop" Version="11.0.0-preview6" />
<PackageReference Include="Avalonia.Desktop" Version="11.0.0-preview8" />
</ItemGroup>
</Project>

Просмотреть файл

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<PackageReference Include="Avalonia.Diagnostics" Version="11.0.0-preview6" />
<PackageReference Include="Avalonia.Diagnostics" Version="11.0.0-preview8" />
</ItemGroup>
</Project>

Просмотреть файл

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.0.0-preview6" />
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.0.0-preview8" />
</ItemGroup>
</Project>

Просмотреть файл

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.0-preview6" />
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.0-preview8" />
</ItemGroup>
</Project>

Просмотреть файл

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.0-preview6" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.0-preview8" />
</ItemGroup>
</Project>

Просмотреть файл

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<PackageReference Include="Avalonia" Version="11.0.0-preview6" />
<PackageReference Include="Avalonia" Version="11.0.0-preview8" />
</ItemGroup>
</Project>

Просмотреть файл

@ -1,10 +1,10 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VersionPrefix>11.0.0</VersionPrefix>
<VersionSuffix>preview6</VersionSuffix>
<VersionSuffix>preview8</VersionSuffix>
<Authors>Wiesław Šoltés</Authors>
<Company>Wiesław Šoltés</Company>
<Copyright>Copyright © Wiesław Šoltés 2021</Copyright>
<Copyright>Copyright © Wiesław Šoltés 2023</Copyright>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/wieslawsoltes/TemplatedDataGrid</PackageProjectUrl>
</PropertyGroup>

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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<TemplatedListBoxItem>(item, out recycleKey);
}
}
}

Просмотреть файл

@ -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);