Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

New Custom Control has empty layout

$
0
0

Hi,

I tried to create a Custom Control in WPF and for some reason the layout is empty. 

My Custom Control is a TextBox.

VS generated this for me:

 public class AutoCompleteTextBox : TextBox
    {
        static AutoCompleteTextBox()
        {            DefaultStyleKeyProperty.OverrideMetadata(typeof(AutoCompleteTextBox), new FrameworkPropertyMetadata(typeof(AutoCompleteTextBox)));
        }
    }

I have found that the above underlined line is what causes the layout to be empty, but deleting it means my control is just a regular text box.

This is my Generic.xml:

<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:TTSoftware_Prod1"
     xmlns:sb="clr-namespace:TTSoftware_Prod1.UserControls.SearchBox"><Style TargetType="{x:Type sb:AutoCompleteTextBox}"><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="{x:Type sb:AutoCompleteTextBox}"><Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"></Border></ControlTemplate></Setter.Value></Setter></Style></ResourceDictionary>

What am I missing? I'm sure it's something stupid but I have been at it for 5 hours.

Thanks in advance!


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>