jav*_*iry 12 wpf xaml label wpf-controls
我更改了Label的样式和模板,如下所示:
<Label Content="Test">
<Label.Style>
<Style TargetType="{x:Type Label}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Border BorderBrush="#DDD" BorderThickness="1" CornerRadius="2" Background="#EEE" Padding="4">
<!--<TextBlock Text="{TemplateBinding Content}" />-->
<ContentPresenter Content="{TemplateBinding Content}" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Label.Style>
</Label>
Run Code Online (Sandbox Code Playgroud)
在设计时,这个作品和设计视图显示所有好东西,(每个TextBlock或ContentPresenter); 但是当我运行项目(或编译它)时,收到此错误:
在"Control"类型上找不到静态成员"ContentProperty".
有人可以帮我吗?非常感谢 ):