C#C
C#2y ago
Pandetthe

Wpf custom button template proble

Hi! I am trying to create custom button control, but I have a problem with a content property. Button is displaying properly if the content is set in it's code, but when I am trying to do this in some view, only it's content is visible without border etc.
<UserControl x:Class="Wacom.TabletApp.Controls.ExtendedButton" 
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"  
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"  
             xmlns:local="clr-namespace:Wacom.TabletApp.Controls" 
             mc:Ignorable="d"  
             d:DataContext="{Binding RelativeSource={RelativeSource Self}}" 
             d:DesignHeight="450" d:DesignWidth="800"> 
    <UserControl.Resources> 
        <SolidColorBrush x:Key="Button.MouseOver.Background" Color="#FFBEE6FD"/> 
        <SolidColorBrush x:Key="Button.MouseOver.Border" Color="#FF3C7FB1"/> 
        <SolidColorBrush x:Key="Button.Pressed.Background" Color="#FFC4E5F6"/> 
        <SolidColorBrush x:Key="Button.Pressed.Border" Color="#FF2C628B"/> 
        <SolidColorBrush x:Key="Button.Disabled.Background" Color="#FFF4F4F4"/> 
        <SolidColorBrush x:Key="Button.Disabled.Border" Color="#FFADB2B5"/> 
        <SolidColorBrush x:Key="Button.Disabled.Foreground" Color="#FF838383"/> 
        <ControlTemplate x:Key="ButtonTemplate" TargetType="{x:Type ButtonBase}"> 
Was this page helpful?