日期:2014-05-17  浏览次数:20864 次

|ZYCWPF| 用户自定义控件,如何给我原来RichTextBox添加事件?
我定义了
public partial class ZRichTextBox : RichTextBox
这个用户控件

    <Style TargetType="{x:Type control:ZRichTextBox}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type control:ZRichTextBox}">
                    <DockPanel LastChildFill="True">
                        <Border DockPanel.Dock="Top" SnapsToDevicePixels="True"
                            BorderBrush="{TemplateBinding ToolbarBorderBrush}"
                            BorderThickness ="{TemplateBinding ToolbarBorderThickness}">
                            <StackPanel Height="24" Orientation="Horizontal"
                                Background="{TemplateBinding ToolbarBackground}">
                            .....这里为我的工具栏按钮
                            </StackPanel>
                        </Border>
                        <ScrollViewer x:Name="PART_ContentHost" VerticalScrollBarVisibility="Auto"  HorizontalScrollBarVisibility="Auto">
                        </ScrollViewer>
                    </DockPanel>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

那我现在要给我的RichTextBox添加MouseLeftButtonUpEvent
我在代码中的话可以用:
        public ZRichTextBox()
        {
this.AddHandler(RichTextBox.MouseLeftButtonUpEvent, new RoutedEventHandler(RichTextMouseClick), true);
        }

但我现在是用MVVM方式写的,要如何进行绑定
        public