how would i add multiple buttons to a window in c#? here\'s what i need to do... i\'m getting multiple user values from a dictionary (within reason, only @ 5-6 values). for
I would encapsulate the whole thing, there normally should be no point in naming the button. Something like this:
public class SomeDataModel
{
public string Content { get; set; }
public ICommand Command { get; set; }
public SomeDataModel(string content, ICommand command)
{
Content = content;
Command = command;
}
}
Then you can create models and put them into a bindable collection:
private readonly ObservableCollection _MyData = new ObservableCollection();
public ObservableCollection MyData { get { return _MyData; } }
Then you just need to add and remove items from that and create buttons on the fly:
For more info see relevant articles on MSDN:
Data Binding Overview
Commanding Overview
Data Templating Overview