Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 12 additions & 33 deletions MainDemo.Wpf/ComboBoxes.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,15 @@
Fill="{DynamicResource MaterialDesignDivider}" />
<TextBlock
Style="{StaticResource SectionTitle}"
Text="Virtualised ComboBoxes"/>
Text="ComboBoxes with long lists"/>

<StackPanel Orientation="Horizontal">

<smtx:XamlDisplay UniqueKey="comboboxes_5" Margin="0">
<ComboBox
materialDesign:HintAssist.Hint="Virtualisation"
MinWidth="72"
ItemsSource="{Binding LongListToTestComboVirtualization}"
ItemsSource="{Binding LongIntegerList}"
SelectedValue="{Binding SelectedValueOne}">

<ComboBox.SelectedItem>
Expand All @@ -174,12 +174,6 @@
</Binding.ValidationRules>
</Binding>
</ComboBox.SelectedItem>

<ComboBox.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel />
</ItemsPanelTemplate>
</ComboBox.ItemsPanel>
</ComboBox>
</smtx:XamlDisplay>

Expand All @@ -188,63 +182,48 @@
<ComboBox materialDesign:HintAssist.Hint="(editable)"
MinWidth="72"
IsEditable="True"
ItemsSource="{Binding LongListToTestComboVirtualization}">
ItemsSource="{Binding LongIntegerList}">
<ComboBox.Text>
<Binding Path="SelectedTextTwo" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged">
<Binding.ValidationRules>
<demoAppDomain:NotEmptyValidationRule ValidatesOnTargetUpdated="True" />
</Binding.ValidationRules>
</Binding>
</ComboBox.Text>
<ComboBox.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel />
</ItemsPanelTemplate>
</ComboBox.ItemsPanel>
</ComboBox>
</smtx:XamlDisplay>
<smtx:XamlDisplay UniqueKey="comboboxes_7">
<ComboBox materialDesign:HintAssist.Hint="(float hint)"
ItemsSource="{Binding LongListToTestComboVirtualization}"
ItemsSource="{Binding LongIntegerList}"
Style="{StaticResource MaterialDesignFloatingHintComboBox}">
<ComboBox.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel />
</ItemsPanelTemplate>
</ComboBox.ItemsPanel>
</ComboBox>
</smtx:XamlDisplay>
<smtx:XamlDisplay UniqueKey="comboboxes_8">
<ComboBox materialDesign:HintAssist.Hint="(large float hint)"
materialDesign:HintAssist.FloatingScale="1.5"
materialDesign:HintAssist.FloatingOffset="0, -24"
MinWidth="72"
ItemsSource="{Binding LongListToTestComboVirtualization}"
ItemsSource="{Binding LongIntegerList}"
Style="{StaticResource MaterialDesignFloatingHintComboBox}">
<ComboBox.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel />
</ItemsPanelTemplate>
</ComboBox.ItemsPanel>
</ComboBox>
</smtx:XamlDisplay>
<smtx:XamlDisplay UniqueKey="comboboxes_12">
<ComboBox materialDesign:HintAssist.Hint="(Change fontfamily float hint)"
materialDesign:HintAssist.FontFamily="Verdana"
MinWidth="72"
ItemsSource="{Binding LongListToTestComboVirtualization}"
ItemsSource="{Binding LongStringList}"
Style="{StaticResource MaterialDesignFloatingHintComboBox}">
<ComboBox.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel />
</ItemsPanelTemplate>
</ComboBox.ItemsPanel>
</ComboBox>
</smtx:XamlDisplay>
</StackPanel>

<StackPanel Orientation="Horizontal" Margin="0,40,0,0">
<materialDesign:PackIcon Kind="Information" Margin="0 0 5 0"/>
<TextBlock>ComboBoxes are virtualized by default in the library</TextBlock>
</StackPanel>

<Rectangle
Margin="0 32 0 0"
Margin="0 15 0 0"
Height="1"
Fill="{DynamicResource MaterialDesignDivider}" />
<TextBlock
Expand Down
11 changes: 11 additions & 0 deletions MainDemo.Wpf/DataGrids.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,20 @@
</materialDesign:MaterialDataGridComboBoxColumn.EditingElementStyle>
-->
</materialDesign:DataGridComboBoxColumn>
<materialDesign:DataGridComboBoxColumn
Header="ComboBox with long list"
SelectedValueBinding="{Binding Files}"
ItemsSourceBinding="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGrid}}, Path=DataContext.Files}">

</materialDesign:DataGridComboBoxColumn>
</DataGrid.Columns>
</DataGrid>
</smtx:XamlDisplay>

<StackPanel Orientation="Horizontal" Margin="0,15,0,0">
<materialDesign:PackIcon Kind="Information" Margin="0 0 5 0"/>
<TextBlock>DataGridComboBoxColumns are virtualized by default in the library</TextBlock>
</StackPanel>

<TextBlock
Style="{StaticResource MaterialDesignHeadline5TextBlock}"
Expand Down
15 changes: 12 additions & 3 deletions MainDemo.Wpf/Domain/ComboBoxesViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace MaterialDesignDemo.Domain
Expand All @@ -12,16 +13,23 @@ public class ComboBoxesViewModel : ViewModelBase

public ComboBoxesViewModel()
{
LongListToTestComboVirtualization = new List<int>(Enumerable.Range(0, 1000));
LongIntegerList = new List<int>(Enumerable.Range(0, 1000));
ShortStringList = new[]
{
"Item 1",
"Item 2",
"Item 3"
};

SelectedValueOne = LongListToTestComboVirtualization.Skip(2).First();
SelectedValueOne = LongIntegerList.Skip(2).First();
SelectedTextTwo = null;

LongStringList = new List<string>();

for(int i = 0; i < 1000; i++)
{
LongStringList.Add(Path.GetRandomFileName());
}
}

public int? SelectedValueOne
Expand All @@ -48,7 +56,8 @@ public string? SelectedValidationOutlined
set => SetProperty(ref _selectedValidationOutlined, value);
}

public IList<int> LongListToTestComboVirtualization { get; }
public IList<int> LongIntegerList { get; }
public IList<string> ShortStringList { get; }
public IList<string> LongStringList { get; }
}
}
11 changes: 11 additions & 0 deletions MainDemo.Wpf/Domain/ListsAndGridsViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;

namespace MaterialDesignDemo.Domain
Expand All @@ -20,6 +21,13 @@ public ListsAndGridsViewModel()
OnPropertyChanged(nameof(IsAllItems1Selected));
};
}

Files = new List<string>();

for (int i = 0; i < 1000; i++)
{
Files.Add(Path.GetRandomFileName());
}
}

public bool? IsAllItems1Selected
Expand Down Expand Up @@ -78,5 +86,8 @@ private static ObservableCollection<SelectableViewModel> CreateData()
public ObservableCollection<SelectableViewModel> Items3 { get; }

public IEnumerable<string> Foods => new[] { "Burger", "Fries", "Shake", "Lettuce" };

public IList<string> Files { get; }

}
}
7 changes: 7 additions & 0 deletions MainDemo.Wpf/Domain/SelectableViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class SelectableViewModel : ViewModelBase
private char _code;
private double _numeric;
private string? _food;
private string? _files;

public bool IsSelected
{
Expand Down Expand Up @@ -44,5 +45,11 @@ public string? Food
get => _food;
set => SetProperty(ref _food, value);
}

public string? Files
{
get => _files;
set => SetProperty(ref _files, value);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1347,6 +1347,14 @@
<Setter Property="wpf:HintAssist.Foreground" Value="{DynamicResource PrimaryHueMidBrush}" />
<Setter Property="Template" Value="{StaticResource MaterialDesignFloatingHintComboBoxTemplate}" />
<Setter Property="internal:ClearText.HandlesClearCommand" Value="True" />
<!--Virtualization-->
<Setter Property="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
<VirtualizingStackPanel />
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsEditable" Value="True">
<Setter Property="IsTabStop" Value="False" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,14 @@
<Setter Property="ScrollViewer.PanningMode" Value="Both"/>
<Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
<Setter Property="Template" Value="{StaticResource MaterialDesignDataGridComboBoxTemplate}"/>
<!--Virtualization-->
<Setter Property="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
<VirtualizingStackPanel />
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsEditable" Value="true">
<Setter Property="IsTabStop" Value="false"/>
Expand Down