Skip to content

SwitchPresenter NullReferenceException #3671

@michael-hawker

Description

@michael-hawker

Describe the bug

Possible to get a NRE using SwitchPresenter.

Steps to Reproduce

    <StackPanel>
        <TextBox x:Name="MyTextBox" />
        <controls:SwitchPresenter Value="{x:Bind MyTextBox.Text, Mode=OneWay}">
            <controls:Case Value="Magic">
                <TextBlock>Everything you do...</TextBlock>
            </controls:Case>
        </controls:SwitchPresenter>
    </StackPanel>

Enter the text 'Magic' in the text box and the case shows as expected; however removing any text after then causes a NRE.

System.NullReferenceException
  HResult=0x80004003
  Message=Object reference not set to an instance of an object.
  Source=Windows
  StackTrace:
   at Windows.UI.Xaml.DependencyObject.SetValue(DependencyProperty dp, Object value)
   at Microsoft.Toolkit.Uwp.UI.Controls.SwitchPresenter.set_Value(Object value)
   at ControlPackagesTest.MainPage.XamlBindingSetters.Set_Microsoft_Toolkit_Uwp_UI_Controls_SwitchPresenter_Value(SwitchPresenter obj, Object value, String targetNullValue) in ControlPackagesTest\ControlPackagesTest\obj\x86\Debug\MainPage.g.cs:line 28

Expected behavior

No NRE

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions