RowDefinitionCollection rd = MainGrid.RowDefinitions;
ColumnDefinitionCollection cd = MainGrid.ColumnDefinitions;
for (int i = 0; i < 3; i++)
{
rd.Add(new RowDefinition());
for (int j = 0; j < 12; j++)
{
cd.Add(new ColumnDefinition());
Button b = new Button();
b.Name = "Button"+i;
MainGrid.Children.Add(b);
Grid.SetColumn(b, j);
Grid.SetRow(b, i);
}
}
public class Panel : INotifyPropertyChanged
{
private string field1;
private string field2;
public event PropertyChangedEventHandler PropertyChanged;
public string Field1
{
get{return field1;}
set{field1 = value; NotifyPropertyChanged("Field1");}
}
public string Field2
{
get{return field2;}
set{field2 = value; NotifyPropertyChanged("Field2");}
}
private void NotifyPropertyChanged(string propertyName = "")
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}
dataGrid.ItemsSource = dataFromMySql;
var timer = new System.Windows.Threading.DispatcherTimer();
timer.Tick += (oe,e)=> dataGrid.Items.Refresh();
/* или */
/* timer.Tick += (oe,e)=> { dataGrid.ItemsSource = null; dataGrid.ItemsSource = dataFromMySql; } */
timer.Interval = new TimeSpan(0,0,10);
timer.Start();