If user checked 'isACreer' and 'oldLibelle' (in same row) is empty, then I show a message box to inform user that is not authorized. How to do that in WPF ?
Here is my wpf code :
<Window.Resources>
<local:_Produits x:Key="_Produits"/>
<CollectionViewSource x:Key="produitsViewSource" Source="{Binding Produits, Source={StaticResource _Produits}}"/>
</Window.Resources>
<DataGrid x:Name="futureProductsDataGrid" Grid.Row="4" Grid.Column="0" Margin="20" ItemsSource="{Binding}" AutoGenerateColumns="False" >
<DataGrid.Columns>
<DataGridTextColumn Header="Code produit vinif" Binding="{Binding codeVinif}" Width="105" IsReadOnly="true"/>
<DataGridTextColumn Header="Libellé Actuel" Binding="{Binding oldLibelle}" Width="SizeToCells" IsReadOnly="true"/>
<DataGridTextColumn Header="Libellé Futur" Binding="{Binding newLibelle, Mode=TwoWay}" Width="SizeToCells"/>
<DataGridCheckBoxColumn Header="A créer ?" Binding="{Binding isACreer, Mode=TwoWay}" Width="80" >
<DataGridCheckBoxColumn.CellStyle>
<Style>
<EventSetter Event="CheckBox.Checked" Handler="OnChecked"/>
</Style>
</DataGridCheckBoxColumn.CellStyle>
</DataGridCheckBoxColumn>
</DataGrid.Columns>
</DataGrid>
Here is my C# code :
private void GetProduits()
{
try
{
_produits = new _Produits();
_produitsProduitsTableAdapter = new ProduitsTableAdapter();
_produitsProduitsTableAdapter.Connection = new OleDbConnection(_connectionString);
_produitsProduitsTableAdapter.Fill(_produits.Produits);
}
catch (Exception ex)
{
_loggerComavi.Error("Erreur lors du chargement de la table Produits");
_loggerComavi.Error(ex.Source);
_loggerComavi.Error(ex.Message);
_loggerComavi.Error(ex.StackTrace);
}
}
private void OnChecked(object sender, RoutedEventArgs e)
{
_loggerComavi.Info("OnChecked");
//TODO MessageBox.show()
}
Aucun commentaire:
Enregistrer un commentaire