fix: fix carousel collection conversion.

This commit is contained in:
rabbitism 2023-03-22 12:02:02 +08:00
parent 3473c754a2
commit 33db3bf0d4
2 changed files with 4 additions and 3 deletions

View File

@ -141,8 +141,8 @@
HorizontalAlignment="Center" HorizontalAlignment="Center"
VerticalAlignment="Center" VerticalAlignment="Center"
ItemContainerTheme="{DynamicResource CarouselIndicatorDotListBoxItem}" ItemContainerTheme="{DynamicResource CarouselIndicatorDotListBoxItem}"
Items="{TemplateBinding Items, ItemsSource="{TemplateBinding Items,
Converter={StaticResource ItemsConverter}}" Converter={StaticResource ItemsConverter}}"
SelectedIndex="{Binding SelectedIndex, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"> SelectedIndex="{Binding SelectedIndex, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}">
<ListBox.ItemsPanel> <ListBox.ItemsPanel>
<ItemsPanelTemplate> <ItemsPanelTemplate>

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.Linq; using System.Linq;
using Avalonia.Collections; using Avalonia.Collections;
using Avalonia.Controls;
using Avalonia.Data.Converters; using Avalonia.Data.Converters;
namespace Semi.Avalonia.Converters; namespace Semi.Avalonia.Converters;
@ -11,7 +12,7 @@ public class ItemToObjectConverter: IValueConverter
{ {
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{ {
if (value is AvaloniaList<object> list) if (value is ItemCollection list)
{ {
return list.Select(a => new object()); return list.Select(a => new object());
} }