Skip to content
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

NullReferenceException with {x:Bind} inside generated code #62

Open
Palatis opened this issue Jun 4, 2019 · 0 comments
Open

NullReferenceException with {x:Bind} inside generated code #62

Palatis opened this issue Jun 4, 2019 · 0 comments

Comments

@Palatis
Copy link

Palatis commented Jun 4, 2019

I'm trying to set a EqualsStateTrigger in a VisualState.StateTriggers with the following code:

<VisualState>
    <VisualState.StateTriggers>
        <triggers:EqualsStateTrigger Value="{x:Bind NavView.IsPaneOpen, Mode=OneWay}" EqualTo="True"/>
    </VisualState.StateTriggers>
    <VisualState.Setters>
        <Setter Target="HorizontalAlignment" Value="Left"/>
    </VisualState.Setters>
</VisualState>

as taken from the example (https://github.com/dotMorten/WindowsStateTriggers/blob/master/src/TestApp/Samples/EqualsSample.xaml)

however it throws NullReferenceException during InitializeComponents().

====== Investigation... ======

digging into generated code (MainPage.g.cs), it calls

public static void Set_WindowsStateTriggers_EqualsStateTrigger_Value(global::WindowsStateTriggers.EqualsStateTrigger obj, global::System.Object value, string targetNullValue)
{
    if (value == null && targetNullValue != null)
    {
        value = (global::System.Object) global::Windows.UI.Xaml.Markup.XamlBindingHelper.ConvertValue(typeof(global::System.Object), targetNullValue);
    }
    obj.Value = value;
}

where obj == null...

I also dug into public void Connect(int connectionId, global::System.Object target) , seems it doesn't call Connect with the IDs for my EqualsStateTriggers:

case 9: // Pages\MainPage.xaml line 138
    this.obj9 = (global::WindowsStateTriggers.EqualsStateTrigger)target;
    break;
case 10: // Pages\MainPage.xaml line 126
    this.obj10 = (global::WindowsStateTriggers.EqualsStateTrigger)target;
    break;

before calling

XamlBindingSetters.Set_WindowsStateTriggers_EqualsStateTrigger_Value(this.obj9, obj, null);

My stack:

MyApp.exe!MyApp.Pages.MainPage.XamlBindingSetters.Set_WindowsStateTriggers_EqualsStateTrigger_Value(WindowsStateTriggers.EqualsStateTrigger obj, object value, string targetNullValue)
MyApp.exe!MyApp.Pages.MainPage.MainPage_obj1_Bindings.Update_NavView_IsPaneOpen(bool obj, int phase)
MyApp.exe!MyApp.Pages.MainPage.MainPage_obj1_Bindings.Update_NavView(Microsoft.UI.Xaml.Controls.NavigationView obj, int phase)
MyApp.exe!MyApp.Pages.MainPage.MainPage_obj1_Bindings.Update_(MyApp.Pages.MainPage obj, int phase)
MyApp.exe!MyApp.Pages.MainPage.MainPage_obj1_Bindings.Update()
MyApp.exe!MyApp.Pages.MainPage.MainPage_obj1_Bindings.Initialize()
MyApp.exe!MyApp.Pages.MainPage.MainPage_obj1_Bindings.Loading(Windows.UI.Xaml.FrameworkElement src, object data)

I'm targeting Windows 10, version 1903 (10.0 build 18362) (both target and minimum).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant