microsoft / microsoft-ui-xaml

Windows UI Library: the latest Windows 10 native controls and Fluent styles for your applications
MIT License
6.35k stars 677 forks source link

WinAppSDK 1.1 stale version, custom dependency property in unpackaged app throw exception #7191

Closed shelllet closed 1 year ago

shelllet commented 2 years ago

Describe the bug

windowsappsdk 1.1 stale versioin, Custom dependencey property in unpackaged app throw exception

exception thrown at 0x00007FFF4B7A474C (KernelBase.dll) in Simple.exe: WinRT originate error - 0x80004005 : 'The property 'File' was not found in type 'Simple.FilePicker'.'. Exception thrown at 0x00007FFF4B7A474C (KernelBase.dll) in Simple.exe: WinRT originate error - 0x802B000A : 'The property 'File' was not found in type 'Simple.FilePicker'. [Line: 0 Position: 0]'.

Steps to reproduce the bug

generic.xaml

     <Style TargetType="local:FilePicker" >
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:FilePicker">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"></ColumnDefinition>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <TextBox x:Name="TextBox" Grid.Column="0" Header="{TemplateBinding Header}" 
                                 DataContext="{TemplateBinding File}"  Text="{Binding Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"></TextBox>
                        <Button x:Name="Button" Grid.Column="1" VerticalAlignment="Bottom">
                            <SymbolIcon Symbol="OpenFile"></SymbolIcon>
                        </Button>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

idl defined:

runtimeclass FilePicker : Microsoft.UI.Xaml.Controls.Control
    {
        FilePicker();
        Object Header;
        String File;
        static Microsoft.UI.Xaml.DependencyProperty HeaderProperty{ get; };
        static Microsoft.UI.Xaml.DependencyProperty FileProperty{ get; };
    }

used:

<local:FilePicker x:Name="_File" Header="Select File" File="{x:Bind ActionData.(local:TypeFile.File), Mode=TwoWay}" ></local:FilePicker>

Expected behavior

everything is ok windowsappsdk 1.0.3

Screenshots

image

NuGet package version

No response

Windows app type

Device form factor

Desktop

Windows version

Windows 11 (21H2): Build 22000

Additional context

image

Scottj1s commented 1 year ago

@shelllet Are you saying this is a regression from Windows App SDK 1.0.3 to 1.1? Can you provide a complete repro project?

shelllet commented 1 year ago

@Scottj1s My project was upgraded Windows App Sdk to 1.2 , and this question didn't appear again

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 5 days.