I need to create a static matrix (need to be datagrid) 10*10 that contain buttons in each cell.
Any one have an idea how to do that?
Thank you all.
Xmal:
<Grid>
<DataGrid ItemsSource="{Binding Arr}">
<DataGrid.ItemTemplate>
<DataTemplate>
<Button />
</DataTemplate>
</DataGrid.ItemTemplate>
</DataGrid>
</Grid>
Code:
namespace WpfApplication4
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
private List<string> m_Arr;
public MainWindow()
{
InitializeComponent();
DataContext = this;
m_Arr = new List<string>();
for (int i = 0; i < 10; i++)
{
m_Arr.Add(i.ToString());
}
}
public List<string> Arr
{
get { return m_Arr; }
set { m_Arr = value; }
}
}
}
> and bind it to a datagrid and this gave me a matrix of int's but i didnt succeeded to change it to buttons instead of int...
– user1606328 Sep 17 '12 at 18:32>` and use two nested ItemsControls, one with a Vertical StackPanel for the `ItemsPanelTemplate` and the other with a Horizontal StackPanel