I have created my own control in WPF. Initially I created it as a usercontrol but found the preferred way to do this is to create a class which inherits from control and then place my respective xaml in a control template inside Generic.xaml
.
This worked fine when it was in my exe but when I moved it to a dll the border disappeared from my control. My control is based off a textbox and is a pretty much a copy and paste of the textbox's control template with the addition of a button the user can click.
I've identified the relevant part of the control template that is not working which is the BorderBrush="{TemplateBinding Border.BorderBrush}"
bit below as well as the next line.
<Style TargetType="{x:Type local:ButtonBox}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:ButtonBox}">
<mwt:ListBoxChrome
Background="{TemplateBinding Panel.Background}"
BorderBrush="{TemplateBinding Border.BorderBrush}"
BorderThickness="{TemplateBinding Border.BorderThickness}"
RenderMouseOver="{TemplateBinding UIElement.IsMouseOver}"
RenderFocused="{TemplateBinding UIElement.IsKeyboardFocusWithin}"
Name="Bd"
SnapsToDevicePixels="True">
I understand template binding but I don't understand why we are binding to Border.BorderBrush
. Where is the border
that we are binding to? The visual tree shows no border that is part of my control. If I replace these 2 lines with hard coded values then I get a border. I suspect there might be something missing from the dll that the exe has such as a style or something that applies to Border??
Thanks in advance for any replies and anyone who took the time to read. Cheers, Michael