Hi,@B M-A . Could you describe more details about what about the buttons methods
refers to? You could also see if the example below is what you want.
- Create a WPF User Control Library named WpfControlLibrary1.
2.Then reference WpfControlLibrary1 in the project.
UserControl1: <StackPanel Orientation="Horizontal">
<Label x:Name="label" Content="Name" Width="100" Height="40"/>
<TextBlock x:Name="tb" Width="100" Height="40" Text="Item1"/>
<Button x:Name="btn" Content="Delete" Width="100" Height="40" Click="btn_Click"/>
</StackPanel> public partial class UserControl1 : UserControl
{
public UserControl1()
{
InitializeComponent();
}
private void btn_Click(object sender, RoutedEventArgs e)
{
MessageBox.Show("Button Click");
}
}
Project:
<Window
xmlns:local="clr-namespace:UserControlInManyWindows"
xmlns:WpfControlLibrary1="clr-namespace:WpfControlLibrary1;assembly=WpfControlLibrary1" x:Class="UserControlInManyWindows.Window1"
mc:Ignorable="d"
Title="Window1" Height="450" Width="800">
<Grid>
<WpfControlLibrary1:UserControl1 HorizontalAlignment="Left" Margin="105,168,0,0" VerticalAlignment="Top"/>
</Grid>
</Window>
You could click UserControl to add it directly to multiple windows.
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.