microsoft / microsoft/microsoft-ui-xaml
Inconsistent Windows.UI.Xaml.Interop.TypeName behavior
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 8.4k
- Forks
- 942
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 105
Description
Describe the bug
I came across this as a sudden whim. I discovered that you can actually construct (or better say implicitly convert) a Windows.UI.Xaml.Interop from a string. If you have a viewmodel like this
runtimeclass ViewModel
{
ViewModel();
Windows.UI.Xaml.Interop.TypeName MyType;
}
You can actually assign MyType in xaml using a string, something like
<Button>
<Button.DataContext>
<local:ViewModel MyType="local:MainWindow" />
</Button.DataContext>
</Button>
If you put a breakpoint in the setter function, you can actually see the TypeName fields are correctly set.
However, if you tried to explicitly construct it, it causes a runtime crash (curiously it compiles):
xmlns:interop="using:Windows.UI.Xaml.Interop" ...
<Button>
<Button.DataContext>
<local:ViewModel>
<local:ViewModel.MyType>
<interop:TypeName>local:MainWindow</interop:TypeName>
</local:ViewModel.MyType>
</local:ViewModel>
</Button.DataContext>
</Button>
Which is the "inconsistent" I am talking about, because something that is implicitly constructed from a string, should also be able to explicitly constructed from a string
Why is this important?
The behavior should be consistent.
Steps to reproduce the bug
As OP.
Actual behavior
No response
Expected behavior
No response
Screenshots
No response
NuGet package version
WinUI 3 - Windows App SDK 1.8.5: 1.8.260209005
Windows version
Windows 10 (1809): Build 17763
Additional context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names no source files, tests, or entry points. Start by reproducing the implicit string assignment and explicit Windows.UI.Xaml.Interop.TypeName construction from the two XAML snippets on Windows App SDK 1.8.5; done means the explicit form no longer crashes and behaves consistently with the implicit form.
Written by the indexing model from the issue text.
Assessment
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100