Home > Software design >  XAML TemplateSelector seems kind of delayed
XAML TemplateSelector seems kind of delayed

Time:09-17

Currently i'm facing a really weird problem. My template selector seems to be some kind of delayed.

Really rough description of my current situation, i'm devolping a simple UWP application with a nested listview to display some items grouped by fixed properties. These Items should be editable by switching the View from "ViewMode" to "EditMode". By enabling the "EditView" the First ListView isn't updated to the EditView template...?! But Why? I Made a complete Demo example which consists of the View User Control, the Main Page and a Demo Model classes as follows (the complete demo on github: enter image description here

CodePudding user response:

XAML TemplateSelector seems kind of delayed

During testing above code sample. it looks nested listview cache cause this problem. you just clear the parent item source. but not clear the nested.

Please find line 36 EditMode set method call _ds.LoadData() to clear nested

public bool EditMode
{
    get { return (bool)GetValue(EditViewProperty); }
    set
    {
        StaticHelper.EditView = value;
        Task.Run(() => { _ds.LoadData(); BuildSource(); });
        SetValue(EditViewProperty, value);
    }
}

Update

<ListView x:Name="list" ItemsSource="{x:Bind MyListCollection, Mode=TwoWay}">
    <ListView.ItemsPanel>
        <ItemsPanelTemplate>
            <StackPanel />
        </ItemsPanelTemplate>
    </ListView.ItemsPanel>
 ......
  • Related