Skip to content

Commit 89738e3

Browse files
authored
Code Quality: Connected drag events to Omnibar (#17245)
1 parent 4c7493f commit 89738e3

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

src/Files.App/UserControls/NavigationToolbar.xaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,10 +384,15 @@
384384
<controls:BreadcrumbBar.ItemTemplate>
385385
<DataTemplate x:DataType="dataitems:PathBoxItem">
386386
<controls:BreadcrumbBarItem
387+
AllowDrop="True"
387388
AutomationProperties.AccessibilityView="Content"
388389
AutomationProperties.Name="{x:Bind Title, Mode=OneWay}"
389390
ChevronToolTip="{helpers:ResourceString Name=BreadcrumbBarChevronButtonToolTip}"
390-
Content="{x:Bind Title, Mode=OneWay}" />
391+
Content="{x:Bind Title, Mode=OneWay}"
392+
DataContext="{x:Bind}"
393+
DragLeave="BreadcrumbBarItem_DragLeave"
394+
DragOver="BreadcrumbBarItem_DragOver"
395+
Drop="BreadcrumbBarItem_Drop" />
391396
</DataTemplate>
392397
</controls:BreadcrumbBar.ItemTemplate>
393398
</controls:BreadcrumbBar>

src/Files.App/UserControls/NavigationToolbar.xaml.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,5 +461,20 @@ private void NavigationButtonOverflowFlyoutButton_LosingFocus(UIElement sender,
461461
if (args.NewFocusedElement is TextBox)
462462
args.Cancel = true;
463463
}
464+
465+
private void BreadcrumbBarItem_DragLeave(object sender, DragEventArgs e)
466+
{
467+
ViewModel.PathBoxItem_DragLeave(sender, e);
468+
}
469+
470+
private async void BreadcrumbBarItem_DragOver(object sender, DragEventArgs e)
471+
{
472+
await ViewModel.PathBoxItem_DragOver(sender, e);
473+
}
474+
475+
private async void BreadcrumbBarItem_Drop(object sender, DragEventArgs e)
476+
{
477+
await ViewModel.PathBoxItem_Drop(sender, e);
478+
}
464479
}
465480
}

src/Files.App/ViewModels/UserControls/NavigationToolbarViewModel.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ private void UserSettingsService_OnSettingChangedEvent(object? sender, SettingCh
467467

468468
public void PathBoxItem_DragLeave(object sender, DragEventArgs e)
469469
{
470-
if (((StackPanel)sender).DataContext is not PathBoxItem pathBoxItem ||
470+
if (((FrameworkElement)sender).DataContext is not PathBoxItem pathBoxItem ||
471471
pathBoxItem.Path == "Home" ||
472472
pathBoxItem.Path == "ReleaseNotes" ||
473473
pathBoxItem.Path == "Settings")
@@ -490,7 +490,7 @@ public async Task PathBoxItem_Drop(object sender, DragEventArgs e)
490490
// Reset dragged over pathbox item
491491
_dragOverPath = null;
492492

493-
if (((StackPanel)sender).DataContext is not PathBoxItem pathBoxItem ||
493+
if (((FrameworkElement)sender).DataContext is not PathBoxItem pathBoxItem ||
494494
pathBoxItem.Path == "Home" ||
495495
pathBoxItem.Path == "ReleaseNotes" ||
496496
pathBoxItem.Path == "Settings")
@@ -521,7 +521,7 @@ public async Task PathBoxItem_Drop(object sender, DragEventArgs e)
521521
public async Task PathBoxItem_DragOver(object sender, DragEventArgs e)
522522
{
523523
if (IsSingleItemOverride ||
524-
((StackPanel)sender).DataContext is not PathBoxItem pathBoxItem ||
524+
((FrameworkElement)sender).DataContext is not PathBoxItem pathBoxItem ||
525525
pathBoxItem.Path == "Home" ||
526526
pathBoxItem.Path == "ReleaseNotes" ||
527527
pathBoxItem.Path == "Settings")

0 commit comments

Comments
 (0)