Browse Source

Remove all remaining uses of Items setter.

pull/10827/head
Steven Kirk 4 years ago
parent
commit
996578f2bf
  1. 4
      samples/BindingDemo/MainWindow.xaml
  2. 2
      samples/ControlCatalog/Pages/TabControlPage.xaml
  3. 8
      samples/VirtualizationDemo/MainWindow.xaml
  4. 2
      src/Avalonia.Controls/Flyouts/MenuFlyout.cs
  5. 2
      src/Avalonia.Controls/Primitives/HeaderedItemsControl.cs
  6. 4
      tests/Avalonia.Markup.Xaml.UnitTests/Xaml/ControlBindingTests.cs

4
samples/BindingDemo/MainWindow.xaml

@ -75,11 +75,11 @@
</StackPanel.DataTemplates> </StackPanel.DataTemplates>
<StackPanel Margin="18" Spacing="4" Width="200"> <StackPanel Margin="18" Spacing="4" Width="200">
<TextBlock FontSize="16" Text="Multiple"/> <TextBlock FontSize="16" Text="Multiple"/>
<ListBox Items="{Binding Items}" SelectionMode="Multiple" Selection="{Binding Selection}"/> <ListBox ItemsSource="{Binding Items}" SelectionMode="Multiple" Selection="{Binding Selection}"/>
</StackPanel> </StackPanel>
<StackPanel Margin="18" Spacing="4" Width="200"> <StackPanel Margin="18" Spacing="4" Width="200">
<TextBlock FontSize="16" Text="Multiple"/> <TextBlock FontSize="16" Text="Multiple"/>
<ListBox Items="{Binding Items}" SelectionMode="Multiple" Selection="{Binding Selection}"/> <ListBox ItemsSource="{Binding Items}" SelectionMode="Multiple" Selection="{Binding Selection}"/>
</StackPanel> </StackPanel>
<ContentControl Content="{ReflectionBinding Selection.SelectedItems[0]}"> <ContentControl Content="{ReflectionBinding Selection.SelectedItems[0]}">
<ContentControl.DataTemplates> <ContentControl.DataTemplates>

2
samples/ControlCatalog/Pages/TabControlPage.xaml

@ -51,7 +51,7 @@
Text="From DataTemplate"> Text="From DataTemplate">
</TextBlock> </TextBlock>
<TabControl <TabControl
Items="{Binding Tabs}" ItemsSource="{Binding Tabs}"
Margin="0 16" Margin="0 16"
DisplayMemberBinding="{Binding Header, x:DataType=viewModels:TabControlPageViewModelItem}" DisplayMemberBinding="{Binding Header, x:DataType=viewModels:TabControlPageViewModelItem}"
TabStripPlacement="{Binding TabPlacement}"> TabStripPlacement="{Binding TabPlacement}">

8
samples/VirtualizationDemo/MainWindow.xaml

@ -11,7 +11,7 @@
Margin="16 0 0 0" Margin="16 0 0 0"
Width="150" Width="150"
Spacing="4"> Spacing="4">
<ComboBox Items="{Binding Orientations}" <ComboBox ItemsSource="{Binding Orientations}"
SelectedItem="{Binding Orientation}"/> SelectedItem="{Binding Orientation}"/>
<TextBox Watermark="Item Count" <TextBox Watermark="Item Count"
UseFloatingWatermark="True" UseFloatingWatermark="True"
@ -26,10 +26,10 @@
UseFloatingWatermark="True" UseFloatingWatermark="True"
Text="{Binding #listBox.Scroll.Viewport, Mode=OneWay}"/> Text="{Binding #listBox.Scroll.Viewport, Mode=OneWay}"/>
<TextBlock>Horiz. ScrollBar</TextBlock> <TextBlock>Horiz. ScrollBar</TextBlock>
<ComboBox Items="{Binding ScrollBarVisibilities}" <ComboBox ItemsSource="{Binding ScrollBarVisibilities}"
SelectedItem="{Binding HorizontalScrollBarVisibility}"/> SelectedItem="{Binding HorizontalScrollBarVisibility}"/>
<TextBlock>Vert. ScrollBar</TextBlock> <TextBlock>Vert. ScrollBar</TextBlock>
<ComboBox Items="{Binding ScrollBarVisibilities}" <ComboBox ItemsSource="{Binding ScrollBarVisibilities}"
SelectedItem="{Binding VerticalScrollBarVisibility}"/> SelectedItem="{Binding VerticalScrollBarVisibility}"/>
<TextBox Watermark="Item to Create" <TextBox Watermark="Item to Create"
UseFloatingWatermark="True" UseFloatingWatermark="True"
@ -44,7 +44,7 @@
</StackPanel> </StackPanel>
<ListBox Name="listBox" <ListBox Name="listBox"
Items="{Binding Items}" ItemsSource="{Binding Items}"
Selection="{Binding Selection}" Selection="{Binding Selection}"
SelectionMode="Multiple" SelectionMode="Multiple"
ScrollViewer.HorizontalScrollBarVisibility="{Binding HorizontalScrollBarVisibility, Mode=TwoWay}" ScrollViewer.HorizontalScrollBarVisibility="{Binding HorizontalScrollBarVisibility, Mode=TwoWay}"

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

@ -90,7 +90,7 @@ namespace Avalonia.Controls
{ {
return new MenuFlyoutPresenter return new MenuFlyoutPresenter
{ {
[!ItemsControl.ItemsProperty] = this[!ItemsProperty], [!ItemsControl.ItemsSourceProperty] = this[!ItemsProperty],
[!ItemsControl.ItemTemplateProperty] = this[!ItemTemplateProperty], [!ItemsControl.ItemTemplateProperty] = this[!ItemTemplateProperty],
[!ItemsControl.ItemContainerThemeProperty] = this[!ItemContainerThemeProperty], [!ItemsControl.ItemContainerThemeProperty] = this[!ItemContainerThemeProperty],
}; };

2
src/Avalonia.Controls/Primitives/HeaderedItemsControl.cs

@ -124,7 +124,7 @@ namespace Avalonia.Controls.Primitives
treeTemplate.Match(item) && treeTemplate.Match(item) &&
treeTemplate.ItemsSelector(item) is { } itemsBinding) treeTemplate.ItemsSelector(item) is { } itemsBinding)
{ {
_itemsBinding = BindingOperations.Apply(this, ItemsProperty, itemsBinding, null); _itemsBinding = BindingOperations.Apply(this, ItemsSourceProperty, itemsBinding, null);
} }
} }

4
tests/Avalonia.Markup.Xaml.UnitTests/Xaml/ControlBindingTests.cs

@ -73,14 +73,14 @@ namespace Avalonia.Markup.Xaml.UnitTests.Xaml
var xaml = @" var xaml = @"
<Window xmlns='https://github.com/avaloniaui'> <Window xmlns='https://github.com/avaloniaui'>
<DockPanel> <DockPanel>
<TabStrip Name='strip' DockPanel.Dock='Top' Items='{Binding Items}' SelectedIndex='0'> <TabStrip Name='strip' DockPanel.Dock='Top' ItemsSource='{Binding Items}' SelectedIndex='0'>
<TabStrip.ItemTemplate> <TabStrip.ItemTemplate>
<DataTemplate> <DataTemplate>
<TextBlock Text='{Binding Header}'/> <TextBlock Text='{Binding Header}'/>
</DataTemplate> </DataTemplate>
</TabStrip.ItemTemplate> </TabStrip.ItemTemplate>
</TabStrip> </TabStrip>
<Carousel Name='carousel' Items='{Binding Items}' SelectedIndex='{Binding #strip.SelectedIndex}'> <Carousel Name='carousel' ItemsSource='{Binding Items}' SelectedIndex='{Binding #strip.SelectedIndex}'>
<Carousel.ItemTemplate> <Carousel.ItemTemplate>
<DataTemplate> <DataTemplate>
<TextBlock Text='{Binding Detail}'/> <TextBlock Text='{Binding Detail}'/>

Loading…
Cancel
Save