- la table "MaTable" contient les champs nom, prenom, appellation, metier
- elle se trouve dans le DataSet "MonDataSet"
- elle resulte d'une requete et comporte plusieurs lignes
-
- 4 textbox dans un StackPanel sont bindées sur la table:
- StackPanel 1.DataContext = MonDataSet.Tables["MaTable"];
-
- code XAML :
-
- <StackPanel1>
- <TextBox Text="{Binding Path=nom, Mode=TwoWay}" />
- <TextBox Text="{Binding Path=prenom, Mode=TwoWay}" />
- <TextBox Text="{Binding Path=appellation, Mode=TwoWay}" />
- <TextBox Text="{Binding Path=metier, Mode=TwoWay}" />
- <StackPanel1 />
-
- CODE C# :
-
-
- // variable de classe
-
- int NumeroDeRow = 0;
- //....
- private void button1_Click(object sender, RoutedEventArgs e) // MoveNext
- {
-
- if NumeroDeRow < MonDataSet.Tables["MaTable"].Rows.Count -1 )
- {
- NumeroDeRow ++;
-
- var contacts = (MonDataSet.Tables["MaTable"] as IListSource).GetList();
-
- DataRowView drv = (DataRowView)contacts[NumeroDeRow];
-
- StackPanel1.DataContext = drv;
- }
- }
-
- private void button2_Click(object sender, RoutedEventArgs e) // MovePrevious
- {
-
- if NumeroDeRow > 0 )
- {
- NumeroDeRow --;
-
- var contacts = (MonDataSet.Tables["MaTable"] as IListSource).GetList();
-
- DataRowView drv = (DataRowView)contacts[NumeroDeRow];
-
- StackPanel1.DataContext = drv;
- }
- }
la table "MaTable" contient les champs nom, prenom, appellation, metier
elle se trouve dans le DataSet "MonDataSet"
elle resulte d'une requete et comporte plusieurs lignes
4 textbox dans un StackPanel sont bindées sur la table:
StackPanel 1.DataContext = MonDataSet.Tables["MaTable"];
code XAML :
<StackPanel1>
<TextBox Text="{Binding Path=nom, Mode=TwoWay}" />
<TextBox Text="{Binding Path=prenom, Mode=TwoWay}" />
<TextBox Text="{Binding Path=appellation, Mode=TwoWay}" />
<TextBox Text="{Binding Path=metier, Mode=TwoWay}" />
<StackPanel1 />
CODE C# :
// variable de classe
int NumeroDeRow = 0;
//....
private void button1_Click(object sender, RoutedEventArgs e) // MoveNext
{
if NumeroDeRow < MonDataSet.Tables["MaTable"].Rows.Count -1 )
{
NumeroDeRow ++;
var contacts = (MonDataSet.Tables["MaTable"] as IListSource).GetList();
DataRowView drv = (DataRowView)contacts[NumeroDeRow];
StackPanel1.DataContext = drv;
}
}
private void button2_Click(object sender, RoutedEventArgs e) // MovePrevious
{
if NumeroDeRow > 0 )
{
NumeroDeRow --;
var contacts = (MonDataSet.Tables["MaTable"] as IListSource).GetList();
DataRowView drv = (DataRowView)contacts[NumeroDeRow];
StackPanel1.DataContext = drv;
}
}