XML : Updating List<> used in xaml and reload frame

So i have an XML file that i load data into a List<> from. That means that i have a main list that contains all the data i need.

From that list i the create variable "sub" lists that i then will use to present data, as needed.

My main window (as for now) contains a frame that i use to load in pages.

My problem is, that i can't figure out how you change the data to be shown on a page, reload it and keep it from showing the standard data.

So i think there a two ways of attacking this, but i need advise on what is the right(working) way.

So on my page1 (loaded into the frame) i have the following code:

  public sealed partial class Page1 : Page  {      public List<Book> Books;      public List<Book> ts1;        public Page1()      {          this.InitializeComponent();          Books = BookManager.GetBooks();          ts1 = Books.Where(p => p.bogNa == "Robert").ToList();      }        private void Update_Click(object sender, RoutedEventArgs e)      {          ts1 = Books.Where(p => p.bogNa != "Robert").ToList();        }  }    

So i can with my button update the list, but obviously when i then reload the frame, we are just back to square one. Can i do it different from the page?

In my page1 xaml i have this code:

  <GridView ItemsSource="{x:Bind ts1}" IsItemClickEnabled="True" SelectionMode="Multiple">          <GridView.ItemTemplate>              <DataTemplate x:DataType="data:Book">                  <StackPanel>                      <Grid Height="200">                          <Grid.RowDefinitions>                              <RowDefinition Height="3*" />                              <RowDefinition Height="1*" />                              <RowDefinition Height="1*" />                              <RowDefinition Height="1*" />                          </Grid.RowDefinitions>                            <Image Grid.Row="0" Name="pic" Width="150" Source="{x:Bind bogCo }"/>                          <TextBlock Grid.Row="1" FontSize ="20" Text="{x:Bind bogNa}" />                          <TextBlock Grid.Row="2" FontSize ="16" Text="{x:Bind bogRe}"/>                          <Button Grid.Row="3" Content="More Info" FontSize="16">                              <Button.Flyout>                                  <Flyout x:Name="FlyoutTest">                                      <TextBlock Text="{x:Bind bogAr}">                                        </TextBlock>                                  </Flyout>                              </Button.Flyout>                          </Button>                      </Grid>                    </StackPanel>              </DataTemplate>          </GridView.ItemTemplate>      </GridView>    

Is there a way to change

  <GridView ItemSource="{x:bind ts1}" ...    

To a different page than page1, like the MainPage?

Iv'e looked into making a data template but i don't know is that is the way to go? because i don't want to spend my time on that, for now, if it leads to the same problems.

No comments:

Post a Comment