【发布时间】:2014-02-25 14:37:36
【问题描述】:
我正在尝试自定义扩展 WPF 工具包的 RichTextBoxFormatBar 工具,因为我想去掉一些开箱即用的功能。
我已经创建了一个自定义控件,并将原始工具源代码复制到Themes\Generic.xaml
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Xceed.Wpf.Toolkit;assembly=Xceed.Wpf.Toolkit"
xmlns:conv="clr-namespace:Xceed.Wpf.Toolkit.Core.Converters;assembly=Xceed.Wpf.Toolkit"
xmlns:MyNamespace="clr-namespace:IsesTextEditor">
<conv:ColorToSolidColorBrushConverter x:Key="ColorToSolidColorBrushConverter" />
<ControlTemplate TargetType="{x:Type MyNamespace:IsesFormatBar}" x:Key="IsesFormatTemplate">
<Border Background="Transparent"
Cursor="Hand"
ToolTip="Click to Drag">
<StackPanel VerticalAlignment="Center"
Width="75">
<Line SnapsToDevicePixels="True"
Stretch="Fill"
StrokeDashArray="1,2"
StrokeThickness="1"
X1="0"
X2="1"
Margin=".5">
<Line.Stroke>
<SolidColorBrush Color="Gray" />
</Line.Stroke>
</Line>
<Line SnapsToDevicePixels="True"
Stretch="Fill"
StrokeDashArray="1,2"
StrokeThickness="1"
X1="0"
X2="1"
Margin=".5">
<Line.Stroke>
<SolidColorBrush Color="Gray" />
</Line.Stroke>
</Line>
<Line SnapsToDevicePixels="True"
Stretch="Fill"
StrokeDashArray="1,2"
StrokeThickness="1"
X1="0"
X2="1"
Margin=".5">
<Line.Stroke>
<SolidColorBrush Color="Gray" />
</Line.Stroke>
</Line>
</StackPanel>
</Border>
</ControlTemplate>
design blah blah design
</StackPanel>
</StackPanel>
</Grid>
</Border>
</ControlTemplate>
<!-- =================================================================== -->
<!-- Style -->
<!-- =================================================================== -->
<Style TargetType="{x:Type MyNamespace:IsesFormatBar}">
<Setter Property="Template"
Value="{StaticResource richTextBoxFormatBarTemplate}" />
<Setter Property="Effect">
<Setter.Value>
<DropShadowEffect BlurRadius="5"
Opacity=".25" />
</Setter.Value>
</Setter>
<Setter Property="Background"
Value="Transparent" />
<Setter Property="IsTabStop"
Value="false" />
</Style>
抱歉,很多 Xaml!
我有Ises.FormatBar.cs,它包含我所有的代码/逻辑并继承自Control.
当我尝试查看 Generic.xaml 的设计器时,我没有看到设计器和消息“有意留空。视觉设计器不支持文档根元素。
可能是我的 xaml 代码未正确绑定到 Ises.FormatBar.cs 的问题?
【问题讨论】: