Bonjour,
voici un cas simple (a priori) :
dans une solution WPF j'ai deux projets : Store (main) et Components.
Dans le projet Component j'ai un UserControl avec un label et un TextBox que je souhaite réutiliser plein de fois dans le projet Store. J'ai donc fait comme suit :

1) Dans le projet Component :
Création d'une classe avec les propriétés du UserControl:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
public class CtrTextBoxProperties : DependencyObject
{
    public static readonly DependencyProperty TextBoxLabelProperty =
        DependencyProperty.Register("TextBoxLabel", typeof(string), typeof(CtrTextBox), new PropertyMetadata(null));
    public string TextBoxLabel
    {
        get => (string)GetValue(TextBoxLabelProperty); set => SetValue(TextBoxLabelProperty, value);
    }
}
Création du UserControl:
Code : 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
<UserControl
    x:Class="Components.CtrTextBox"
    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:prop="clr-namespace:Components"
    d:DataContext="{d:DesignInstance Type=prop:CtrTextBoxProperties}"
    d:DesignHeight="50"
    d:DesignWidth="800"
    mc:Ignorable="d">
    <StackPanel Orientation="Horizontal">
        <Label Content="{Binding TextBoxLabel}" />
        <TextBox Width="300" Margin="5" />
    </StackPanel>
</UserControl>
2) Dans le projet Store
ajout d'une référence au projet Component.
Dans le MainWindow j'appelle le UserControl

Code : 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
18
19
20
21
22
<Window
    x:Class="Store.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:ucs="clr-namespace:Components;assembly=Components"
    Title="MainWindow"
    Width="800"
    Height="450"
    mc:Ignorable="d">
    <Grid >
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <ucs:CtrTextBox
            TextBoxLabel
    </Grid>
</Window>
Et voici une capture d'écran qui montre que la propriété TextBoxLabel n'est pas reconnue...

Nom : Capture d’écran 2023-09-14 053131.png
Affichages : 119
Taille : 37,0 Ko

Comment faire à votre avis ??