File tree Expand file tree Collapse file tree 6 files changed +41
-28
lines changed Expand file tree Collapse file tree 6 files changed +41
-28
lines changed Original file line number Diff line number Diff line change 4
4
using Microsoft . UI . Xaml ;
5
5
using Microsoft . UI . Xaml . Controls ;
6
6
7
- namespace Files . App . TemplateSelectors
7
+ namespace Files . App . Data . TemplateSelectors
8
8
{
9
9
internal abstract class BaseTemplateSelector < TItem > : DataTemplateSelector
10
10
{
Original file line number Diff line number Diff line change 4
4
using Files . Backend . ViewModels . Dialogs . FileSystemDialog ;
5
5
using Microsoft . UI . Xaml ;
6
6
7
- namespace Files . App . TemplateSelectors
7
+ namespace Files . App . Data . TemplateSelectors
8
8
{
9
9
internal sealed class FileSystemDialogItemSelector : BaseTemplateSelector < BaseFileSystemDialogItemViewModel >
10
10
{
Original file line number Diff line number Diff line change
1
+ // Copyright (c) 2023 Files Community
2
+ // Licensed under the MIT License. See the LICENSE.
3
+
4
+ using Microsoft . UI . Xaml ;
5
+ using Microsoft . UI . Xaml . Controls ;
6
+
7
+ namespace Files . App . Data . TemplateSelectors
8
+ {
9
+ /// <summary>
10
+ /// Provides template selector for Path Breadcrumb template items.
11
+ /// </summary>
12
+ internal sealed class PathBreadcrumbItemSelector : DataTemplateSelector
13
+ {
14
+ public DataTemplate ? ParentItems { get ; set ; }
15
+
16
+ public DataTemplate ? CurrentItem { get ; set ; }
17
+
18
+ protected override DataTemplate SelectTemplateCore ( object item , DependencyObject container )
19
+ {
20
+ var itemsControl = ItemsControl . ItemsControlFromItemContainer ( container ) ;
21
+
22
+ if ( itemsControl . ItemsSource is ObservableCollection < PathBoxItem > items )
23
+ {
24
+ return
25
+ itemsControl . IndexFromContainer ( container ) == items . Count - 1
26
+ ? CurrentItem !
27
+ : ParentItems ! ;
28
+ }
29
+ else
30
+ {
31
+ throw new ArgumentException ( $ "Type of { nameof ( itemsControl . ItemsSource ) } doesn't match ObservableCollection<{ nameof ( PathBoxItem ) } >") ;
32
+ }
33
+ }
34
+ }
35
+ }
Original file line number Diff line number Diff line change 7
7
xmlns:d=" http://schemas.microsoft.com/expression/blend/2008"
8
8
xmlns:helpers=" using:Files.App.Helpers"
9
9
xmlns:mc=" http://schemas.openxmlformats.org/markup-compatibility/2006"
10
- xmlns:ts =" using:Files.App.TemplateSelectors"
10
+ xmlns:templateselectors =" using:Files.App.Data .TemplateSelectors"
11
11
xmlns:tvc=" using:CommunityToolkit.WinUI.UI.Converters"
12
12
xmlns:vm=" using:Files.Backend.ViewModels.Dialogs.FileSystemDialog"
13
13
x:Name=" RootDialog"
213
213
SelectionMode=" None" >
214
214
215
215
<ListView .ItemTemplateSelector>
216
- <ts : FileSystemDialogItemSelector ConflictItemDataTemplate =" {StaticResource ConflictItemDataTemplate}" DefaultItemDataTemplate =" {StaticResource DefaultItemDataTemplate}" />
216
+ <templateselectors : FileSystemDialogItemSelector ConflictItemDataTemplate =" {StaticResource ConflictItemDataTemplate}" DefaultItemDataTemplate =" {StaticResource DefaultItemDataTemplate}" />
217
217
</ListView .ItemTemplateSelector>
218
218
219
219
<ListView .ItemsPanel>
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 7
7
xmlns:Interactivity=" using:Microsoft.Xaml.Interactivity"
8
8
xmlns:d=" http://schemas.microsoft.com/expression/blend/2008"
9
9
xmlns:dataitem=" using:Files.App.Data.Items"
10
- xmlns:helpers=" using:Files.App.Helpers"
11
10
xmlns:mc=" http://schemas.openxmlformats.org/markup-compatibility/2006"
11
+ xmlns:templateselectors=" using:Files.App.Data.TemplateSelectors"
12
12
d:DesignHeight=" 300"
13
13
d:DesignWidth=" 400"
14
14
mc:Ignorable=" d" >
172
172
</ListView .ItemContainerTransitions>
173
173
174
174
<ListView .ItemTemplateSelector>
175
- <helpers : ItemsDataTemplateSelector CurrentItem =" {StaticResource CurrentItem}" ParentItems =" {StaticResource ParentItems}" />
175
+ <templateselectors : PathBreadcrumbItemSelector CurrentItem =" {StaticResource CurrentItem}" ParentItems =" {StaticResource ParentItems}" />
176
176
</ListView .ItemTemplateSelector>
177
177
178
178
</ListView >
You can’t perform that action at this time.
0 commit comments