Skip to content

ListDetailsView navigation data loss #3546

@huwpascoe

Description

@huwpascoe

Describe the bug

MasterDetailsView, navigation events are processed in incorrect order resulting in data loss for controls that use {x:Bind UpdateSourceTrigger=LostFocus} type binding.

Steps to Reproduce

    public class MyItem
    {
        public string MyName { get; set; }
        public string MyValue { get; set; }
    }

    public class ViewModel
    {
        public ObservableCollection<MyItem> Items { get; set; } = new ObservableCollection<MyItem>()
        {
            new MyItem(){ MyName = "Alice" },
            new MyItem(){ MyName = "Bob" },
        };
    }
    <Page.Resources>
        <DataTemplate x:Key="ListTemplate" x:DataType="local:MyItem">
            <TextBlock Text="{x:Bind MyName}" />
        </DataTemplate>
        <DataTemplate x:Key="DetailsTemplate" x:DataType="local:MyItem">
            <StackPanel Margin="16">
                <TextBlock Text="{x:Bind MyName}" FontSize="32" />
                <TextBox Header="Value" Text="{x:Bind MyValue, Mode=TwoWay}" />
                <TextBox Header="Dummy" />
            </StackPanel>
        </DataTemplate>
    </Page.Resources>
    <Grid>
        <controls:MasterDetailsView
          ItemsSource="{x:Bind ViewModel.Items}"
          ItemTemplate="{StaticResource ListTemplate}"
          DetailsTemplate="{StaticResource DetailsTemplate}"
          NoSelectionContent="Select an item" />
    </Grid>

Expected behavior

MasterDetailsView
1 ItemSelected
2 LostFocus => {x:Bind} saves data
3 Navigate

Actual Behavior

1 ItemSelected
2 Navigate => unsaved data overwritten
3 LostFocus

Screenshots

bug

Environment

NuGet Package(s): 
Microsoft.NETCore.UniversalWindowsPlatform
Microsoft.Toolkit.Uwp.UI.Controls

Package Version(s): 
6.2.10
6.1.1

Windows 10 Build Number:
- [ ] Fall Creators Update (16299)
- [ ] April 2018 Update (17134)
- [ ] October 2018 Update (17763)
- [ ] May 2019 Update (18362)
- [x] May 2020 Update (19041)
- [ ] Insider Build (build number: )

App min and target version:
- [ ] Fall Creators Update (16299)
- [ ] April 2018 Update (17134)
- [x] October 2018 Update (17763)
- [ ] May 2019 Update (18362)
- [x] May 2020 Update (19041)
- [ ] Insider Build (xxxxx)

Device form factor:
- [x] Desktop
- [ ] Xbox
- [ ] Surface Hub
- [ ] IoT

Visual Studio 
- [ ] 2017 (version: )
- [x] 2019 (version: 16.7.5) 
- [ ] 2019 Preview (version: )

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions