Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I would highly recommend looking into the MVVM design pattern when working with WPF</p> <p>That said, I would bind my XAML to an <code>ObservableCollection&lt;SomeObject&gt;</code>, and clicking the <code>AddButton</code> would add a new <code>SomeObject</code> to the <code>ObservableCollection</code>. This would make the UI automatically add the new row when the collection gets updated, and <code>SomeObject</code> could have properties for <code>IsM1Visible</code>, <code>IsM2Visible</code>, and <code>IsM3Visible</code> which determines which buttons are visible.</p> <p>For example,</p> <p>Class <code>SomeObject</code> would have</p> <pre><code>string Name; string City; int Age; int Count; bool IsM1Visible; bool IsM2Visible; bool IsM3Visible; </code></pre> <p>The XAML would look something like this:</p> <pre><code>&lt;ItemsControl ItemsSource="{Binding SomeCollection}"&gt; &lt;ItemsControl.ItemTemplate&gt; &lt;DataTemplate&gt; &lt;WrapPanel&gt; &lt;TextBox Text="{Binding Name}" Margin="10,10" Height="20" &gt;&lt;/TextBox&gt; &lt;TextBox Text="{Binding City}" Margin="10,10" Height="20" &gt;&lt;/TextBox&gt; &lt;TextBox Text="{Binding Age}" Margin="10,10" Height="20"&gt;&lt;/TextBox&gt; &lt;TextBox Text="{Binding Count}" Margin="10,10" Height="20" &gt;&lt;/TextBox&gt; &lt;Button Content="M1" Visibility="{Binding IsM1Visible, Converter="{StaticResource BooleanToVisibilityConverter}" Margin="10,10" Height="20"/&gt; &lt;Button Content="M2" Visibility="{Binding IsM2Visible, Converter="{StaticResource BooleanToVisibilityConverter}" Margin="10,10" Height="20"/&gt; &lt;Button Content="M3" Visibility="{Binding IsM3Visible, Converter="{StaticResource BooleanToVisibilityConverter}" Margin="10,10" Height="20"/&gt; &lt;/WrapPanel&gt; &lt;/DataTemplate&gt; &lt;/ItemsControl.ItemTemplate&gt; &lt;/ItemsControl&gt; </code></pre> <p>And the Add Button's Click event would look something like this:</p> <pre><code>void AddButton_Click(object sender, EventArgs e) { var newItem = new SomeItem { Name = "Something", City = "Something", Age = 30, Count = 2, IsM1Visible = true, IsM2Visible = false, IsM3Visible = true }; SomeCollection.Add(newItem); } </code></pre>
 

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