microsoft / microsoft/microsoft-ui-xaml

Flyout.ShowAt Does not work correctly With DependencyObject and shows wrong error message (simple repro)

Open
#10,954 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area-Flyouts bug
Dominant language
C++
Stars
8.4k
Forks
942
Avg merge
2d 7h
Merged PRs (30d)
105

Description

### Describe the bug

Dear Winui3 developers,

today I encountered a very easy to reproduce error:
Using the Visual Studio 2026 starting project for a winui3 App, consider the MainWindow.xaml:
```






Click_me


```

And the MainWindow.Xaml.cs:
```
using System.Diagnostics;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls.Primitives;
using Microsoft.UI.Xaml.Documents;

namespace App1;

///
/// An empty window that can be used on its own or navigated to within a Frame.
///
public sealed partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}

private void Hyperlink_OnClick(Hyperlink sender, HyperlinkClickEventArgs args)
{
var flyoutShowOptions = new FlyoutShowOptions()
{
Placement = FlyoutPlacementMode.Auto
};

var flyout = new Flyout()
{
Content = new TextBlock()
{
Text = "Hello, World!"
}
};
flyout.ShowAt(sender, flyoutShowOptions);
}
}
```

When the Hyperlink is clicked the following error crashes the app: "At least one property in FlyoutShowOptions must be set."

### Why is this important?

Scenario: Created a control like in MS Outlook, filter for emails. A text where some parts are parameters, changeable by the user. Using "hyperlink" Inline to show a flyout where the new parameter value can be set.

### Steps to reproduce the bug

Shown in the issue text

### Actual behavior

1. An exception of type 'System.ArgumentException' occurred in WinRT.Runtime.dll but was not handled in user code
2. "Wrong Parameter. \r\n \r\n At least one property in FlyoutShowOptions must be set."

Error message is wrong, one can clearly see that at least one parameter is set.
Copilot suggests that the sender might not be a FrameworkElement, but according to https://learn.microsoft.com/en-us/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.documents.hyperlink?view=windows-app-sdk-1.8 it is a **DependencyObject**.
And for **Flyout.ShowAt**() there is an overload accepting an **DependencyObject**: https://learn.microsoft.com/en-us/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.controls.primitives.flyoutbase.showat?view=windows-app-sdk-1.8

### Expected behavior

1. The flyout can be shown
2. If the flyout can not be shown, the error message tells us why and does not show something that is obviously not true

### Screenshots

_No response_

### NuGet package version

WinUI 3 - Windows App SDK 1.8.3: 1.8.251106002

### Windows version

Windows 11 (24H2): Build 26100

### Additional context

_No response_

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the MainWindow.xaml and MainWindow.Xaml.cs reproduction, then trace the Flyout.ShowAt overload that accepts a DependencyObject and the validation path producing the exception. Verify the behavior with the provided WinUI 3 1.8.3 sample. Done means the flyout can be shown from a Hyperlink, or an accurate error explains why it cannot.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, csharp
Domain
desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.