Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here is a REALLY basic example using MVVM.</p> <p>XAML:</p> <pre><code>&lt;Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}"&gt; &lt;GridView ItemsSource="{Binding Things}"&gt; &lt;GridView.ItemTemplate&gt; &lt;DataTemplate&gt; &lt;Button Width="100" Height="100" Background="Red" Content="{Binding Name}" Click="CriticalClick" DataContext="{Binding}"&gt;&lt;/Button&gt; &lt;/DataTemplate&gt; &lt;/GridView.ItemTemplate&gt; &lt;/GridView&gt; &lt;/Grid&gt; </code></pre> <p>ViewModel &amp; Model:</p> <pre><code>public class ThingViewModel { public ObservableCollection&lt;Thing&gt; Things { get; set; } public ThingViewModel() { var allThings = new List&lt;Thing&gt;(); for (int i = 0; i &lt; 30; i++) { if (i % 2 == 0) allThings.Add(new Thing { Name = "Critical" }); else allThings.Add(new Thing { Name = "`NonCritical" }); } this.Things = new ObservableCollection&lt;Thing&gt;(allThings.Where(x =&gt; x.Name == "Critical")); } } public class Thing { public string Name { get; set; } } </code></pre> <p>Code Behind:</p> <pre><code>protected override void OnNavigatedTo(NavigationEventArgs e) { this.DataContext = new ThingViewModel(); } private void CriticalClick(object sender, RoutedEventArgs e) { var tappedThing = (Thing) ((Button) sender).DataContext; ((ThingViewModel) this.DataContext).Things.Remove(tappedThing); } </code></pre> <p>This is a really simple example of how to do it with binding and MVVM. It gives you a starting point for what you are asking for though.</p> <p>Hope it helps.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload