Hi,@Roger Schlueter. Not sure about your specific code. For questions about how to use custom controls correctly, you could try to refer to my solution.
Here is a sample you can refer to:
project structure:
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfCustomControlLibrary1">
<Style TargetType="{x:Type local:CustomControl1}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:CustomControl1}">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<Label Content="Hello, World" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
- Create a new or open an existing WPF project.
- Right-click on the project, select "Add" > "Project Reference..."
- Browse and select the DLL file generated by your custom control library project (e.g., WpfCustomControlLibrary1.dll).
- You could use references as follows in your senario:
xmlns:MyNamespace="clr-namespace:RSComboBox;assembly=RSComboBox"
RSComboBox
MainWindow.xaml:
<Window x:Class="CustomControlUsing.MainWindow"
...
xmlns:rs="clr-namespace:WpfCustomControlLibrary1;assembly=WpfCustomControlLibrary1"
xmlns:local="clr-namespace:CustomControlUsing"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<rs:CustomControl1 x:Name="customControl1" HorizontalAlignment="Left" Height="100" Margin="10,10,0,0" VerticalAlignment="Top" Width="100" />
</Grid>
</Window>
The result:
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
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.