Hello
In a form, i generate several buttons, with binding.
In a XML :
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="0.1*" />
<RowDefinition Height="0.85*" />
<RowDefinition Height="0.15*" />
</Grid.RowDefinitions>
<ItemsControl x:Name="lvDataBinding" HorizontalContentAlignment="Stretch" BorderThickness="0" Margin="10" Grid.Row="1" Background="{x:Null}" ItemsSource="{Binding}" Grid.ColumnSpan="4" Foreground="White">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border BorderBrush="White" BorderThickness="1" CornerRadius="3" Margin="0,3" Grid.ColumnSpan="0" Background="Transparent" HorizontalAlignment="Left" VerticalAlignment="Top">
<StackPanel Orientation="Vertical" >
<CheckBox x:Name="cbxLignes" Tag="{Binding strCodeLigne}" Style="{StaticResource {x:Type ToggleButton}}" Content="{Binding strCodeLigne}" FontSize="22" Margin="25,15,25,15" Width="100" Height="45" IsChecked="{Binding IsChecked}" Checked="cbxLignes_Checked" Unchecked="cbxLignes_Unchecked" />
</StackPanel>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
<Button Name="btnValider" Grid.Row="4" Grid.Column="2" Content="Valider" Background="#5491fe" Margin="95,5,5,5" Click="btnValider_Click" />
<Button Name="btnTous" Grid.Row="4" Grid.Column="0" Content="Tous" Background="#5491fe" Margin="95,5,5,5" Click="btnTous_Click" />
<Button Name="btnAucuns" Grid.Row="4" Grid.Column="1" Content="Aucun" Background="#5491fe" Margin="5,5,95,5" />
<Button Name="btnAnnuler" Grid.Row="4" Grid.Column="3" Content="Annuler" Background="#5491fe" Margin="5,5,95,5" Click="btnAnnuler_Click" />
</Grid>
My binding is generate with SQL values :
for (int i = 0; i < dvLignes.Count; i++)
{
clLignes = new CL_Lignes();
clLignes.strCodeLigne = dvLignes[i]["CodeLigne"].ToString().Trim();
lstLignes.Add(clLignes);
this.DataContext = lstLignes;
}
I need with a button, check all checkboxes generate. I don't know in advance how and which text buttons has generate
Thank you in advance.
What I have tried:
I try to find a loop, but i don't found