Reputation: 382
I have a button with flyout menu inside it, when user clicks on this button app crashes. It work's fine in build version 10586.
Getting Error: "Failed to assign to property 'Windows.UI.Xaml.FrameworkElement.MinWidth'"
Below is the code:
<Button x:Name="btnMore"
Style="{StaticResource DesktopAppBarButtonStyle}">
<StackPanel Orientation="Horizontal">
<SymbolIcon Symbol="More"></SymbolIcon>
</StackPanel>
<Button.Flyout>
<MenuFlyout Placement="Bottom">
<MenuFlyoutItem Text="Menu1"></MenuFlyoutItem>
<MenuFlyoutItem Text="Menu2"></MenuFlyoutItem>
<MenuFlyoutItem Text="Menu3"></MenuFlyoutItem>
</MenuFlyout>
</Button.Flyout>
</Button>
In my DesktopAppBarButtonStyle I have below line which causes error:
MinWidth="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.FlyoutContentMinWidth}"
Upvotes: 1
Views: 529
Reputation: 10015
Pinpointing the error to your style is the first step to solving it. The FlyoutContentMinWidth
property is a new property in 10586, according to this diff (almost at the bottom, in fact it seems to be added between 10532 and 10547).
If it would have been a C# code feature, you could have solved your issue by using the Windows.Foundation.Metadata.ApiInformation API to check for the availability of the feature, but since it's XAML you'll have to set your minimum version to 10586.
any new resource keys added to generic.xaml and not available in a previous version. The version of generic.xaml used at runtime is determined by the OS version the device is running on. You can't use runtime API checks to determine the presence of XAML resources. So, you must only use resource keys that are available in the minimum version that your app supports or a XAMLParseException will cause your app to crash at runtime.
Source: https://msdn.microsoft.com/en-us/windows/uwp/debug-test-perf/version-adaptive-code
Upvotes: 2