Bonjour,
Couramment, j'utilise un fichier CommandesPerso pour stocker mes commandes déclarées comme ça dans mon xaml de la fenètre :

Code XAML : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<Window x:Name="WindowMain" x:Class="MonProjet.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:commentaire="Texte sans interet"
        xmlns:local="clr-namespace:MonProjet"
        mc:Ignorable="d commentaire"
        WindowStartupLocation="CenterScreen" Height="500" Width="1100"  Style="{DynamicResource Fenetre}">
    <Window.CommandBindings>
        <!--1 - Déclarer ici les commandes soit celles des librairies soit des commandes perso.-->
        <CommandBinding Command="Close" Executed="Close_Executed"/>
        <CommandBinding Command="local:CommandesPerso.MiseALHeure" Executed="MiseALHeure_Executed"/>
        <CommandBinding Command="local:CommandesPerso.InsereHeure" Executed="InsereHeure_Executed"/>
        <CommandBinding Command="local:CommandesPerso.InsereDate" Executed="InsereDate_Executed"/>
    </Window.CommandBindings>
.../...

Ces trois lignes sont en erreur : "La valeur ne peut pas être null. Nom du paramètre : value."
Le programme fonctionne parfaitement et notamment mes 3 commandes en erreur.
Si je recopie ce code en dehors, je n'arrive pas à reproduire cette erreur.
Code XAML : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
        <CommandBinding Command="local:CommandesPerso.MiseALHeure" Executed="MiseALHeure_Executed"/>
        <CommandBinding Command="local:CommandesPerso.InsereHeure" Executed="InsereHeure_Executed"/>
        <CommandBinding Command="local:CommandesPerso.InsereDate" Executed="InsereDate_Executed"/>

La classe CommandesPerso est comme ça :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
using System.Windows.Input;
 
 
namespace MonProjet
{
    public static class CommandesPerso
    {
        //Déclaration des commandes personnalisées
        public static RoutedUICommand MiseALHeure = new RoutedUICommand();
        public static RoutedUICommand InsereHeure = new RoutedUICommand();
        public static RoutedUICommand InsereDate = new RoutedUICommand();
 
    }
}
QQn peut m'aider.
Merci d'avance