microsoft / microsoft/microsoft-ui-xaml
Use CommandBarFlyout in page resource, throw Value does not fall within the expected range
- Dominant language
- C++
- Stars
- 8.4k
- Forks
- 942
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 105
Description
### Describe the bug
The commandBarFlyout.ShowAt() function throw an Exception: Value does not fall within the expected range.
The CommandBarFlyout Control is defined in page resources:
```xaml
```
Here's the invoke event:
```csharp
private void GridView_RightTapped(object sender, Microsoft.UI.Xaml.Input.RightTappedRoutedEventArgs e)
{
if (sender is Grid grid && grid.DataContext is BlueprintInfoViewData blueprintInfoViewData)
{
commandBarFlyout.ShowAt(grid);
}
}
```
This event is binding to the GridView's RightTapped event.
I have tried to set the XamlRoot in CommandBarFlyout, but it doesn't work.
### Steps to reproduce the bug
Defined the CommandBarFlyItem in page resources, and binding the GridView's RightTapped event.
The right click anywhere in gridView control, then the exception throw.
### Expected behavior
_No response_
### Screenshots

### NuGet package version
WinUI 3 - Windows App SDK 1.6.2: 1.6.241106002
### Windows version
_No response_
### Additional context
_No response_
Contributor guide
Research direction
The report names CommandBarFlyout.ShowAt(grid) in the GridView_RightTapped handler and uses Windows App SDK 1.6.2. Reproduce the page-resource scenario first, then trace the CommandBarFlyout implementation and existing tests; done means the handler no longer throws "Value does not fall within the expected range" for the supplied markup.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100