Pet*_*ete 2 c# wpf xaml custom-controls
我正在尝试我的第一个 WPF 自定义控件。我几乎没有做过任何事情,它不会编译。我在 generic.xaml 中收到错误消息:“类型引用找不到名为“Filmstrip”的公共类型。第 7 行位置 50(第 7 行是样式开始标记)
通用.xaml:
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespaces:Unicorn.Controls">
<Style TargetType="{x:Type local:Filmstrip}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:Filmstrip}">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
Run Code Online (Sandbox Code Playgroud)
幻灯片.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace Unicorn.Controls
{
public class Filmstrip : Control
{
static Filmstrip()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(Filmstrip), new FrameworkPropertyMetadata(typeof(Filmstrip)));
}
}
}
Run Code Online (Sandbox Code Playgroud)
我缺少什么?
| 归档时间: |
|
| 查看次数: |
6816 次 |
| 最近记录: |