-
Notifications
You must be signed in to change notification settings - Fork 678
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Critical crash in WinUI with attached properties in style. #6388
Comments
FYI @MikeHillberg |
I have the same issue, here's another repro: App176.zip. Here's a extract: <!-- This crashes the app-->
<ContentControl Content="42">
<ContentControl.Template>
<ControlTemplate TargetType="ContentControl">
<Grid>
<Border Tag="{Binding Path=(local:TestControlExtensions.MyProperty)}" />
</Grid>
</ControlTemplate>
</ContentControl.Template>
</ContentControl>
<!--
This works:
<ContentControl Content="42" local:TestControlExtensions.MyProperty="{x:Null}">
<ContentControl.Template>
<ControlTemplate TargetType="ContentControl">
<Grid>
<Border Tag="{Binding Path=(local:TestControlExtensions.MyProperty)}" />
</Grid>
</ControlTemplate>
</ContentControl.Template>
</ContentControl>
--> With this attached property: [Microsoft.UI.Xaml.Data.Bindable]
public static class TestControlExtensions
{
public static DependencyProperty MyPropertyProperty { get; } = DependencyProperty.RegisterAttached(
"MyProperty",
typeof(object),
typeof(TestControlExtensions),
new PropertyMetadata(default));
public static object GetMyProperty(Control obj) => (object)obj.GetValue(MyPropertyProperty);
public static void SetMyProperty(Control obj, object value) => obj.SetValue(MyPropertyProperty, value);
} |
@jeromelaban I do not think what it is the same. I initialize all attached properties in styles. But take a look:
I only create CrashButtonStyle and do not use it. If I'll comment it in MainWindow.xaml and uncomment it in CommonStyles.xaml - I will not have any problem. (p.s. property from CrashButtonStyle not uses in template) Because of that, I can't use attached property in style, If I use such styles it is some assemblies. To not catch this bug - I should hold all styles in one assembly (and in one file because of other bug with resource files separation, but it is other story). WinUI have problem with attached property initialization. |
Any update on this? More than a year has been passed =( |
+1 |
Describe the bug
You will have unexpected crash in WinUI 3 If you have a style with attached property.
Steps to reproduce the bug
If we click the button - we have crash.
Same in my native language ->
По нажатию на кнопку - падаем.
Expected behavior
No crash.
Screenshots
No response
NuGet package version
WinUI 3 - Windows App SDK 1.0 (If you're seeing your issue in older previews of WinUI 3, please try this release)
Windows app type
Device form factor
Desktop
Windows version
May 2021 Update (19043)
Additional context
See attached project
TestForMS.zip
@gabbybilka Looks like you have critical crash in WinUI. I added a simple project. Could somebody take a look?
The text was updated successfully, but these errors were encountered: