WPF - 从ButtonBase创建自定义控件 - 继承类仍然是抽象的?

时间:2016-09-20 17:55:51

标签: c# wpf xaml inheritance abstract

我在WPF中有一个名为" JButton"的自定义控件。我从ButtonBase继承而且我把它放在我的MainWindow中,我得到错误" JButton类型是抽象的,我不知道为什么。我甚至不确定如何从Windows文档中告诉哪些方法是抽象的,我需要提供实现。

MainWindow.xaml

<Window x:Class="WpfApplicationJ.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:project="clr-namespace:WpfApplicationJ"
    Title="MainWindow" Height="700" Width="1000">
<DockPanel>
    <Border BorderThickness="1" DockPanel.Dock="Top" Height="27"    Background="White" BorderBrush="Black">
        <TextBlock Margin="2">

        </TextBlock>
    </Border>
    <Border BorderThickness="1" DockPanel.Dock="Bottom" Height="27" Background="White" BorderBrush="Black" VerticalAlignment="Bottom">
        <TextBox IsReadOnly="True"></TextBox>
    </Border>
    <DockPanel DockPanel.Dock="Right" Width="200" HorizontalAlignment="Right">
        <Border DockPanel.Dock="Top" BorderBrush="Black" BorderThickness="1,0,1,0" Width="200" HorizontalAlignment="Right" Background="White" Padding="2">
            <Border BorderBrush="#FFBBBBBB" BorderThickness="2">
                <TextBox Margin="2" TextWrapping="Wrap">
                    Text Text Text Text text Text Text Text Text
                </TextBox>
            </Border>
        </Border>
        <project:JButton/>


    </DockPanel>
</DockPanel>
</Window>

JButton.xaml

<ButtonBase
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 x:Class="WpfApplicationJ.JButton">
<Border BorderThickness="1" BorderBrush="Black" Background="#FF34F6FF" >

</Border>
</ButtonBase>

JButton.xaml.cs

namespace WpfApplicationJ
{
/// <summary>
/// Interaction logic for JButton.xaml
/// </summary>
public partial class JButton : ButtonBase
{


    public JButton()
    {

    }
}
}

0 个答案:

没有答案