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

|ZYCWPF| 自定义的RichTextBox,剪切可以复制,但没有切掉内容,如何把菜单写在自定义控件的Generic里面,缩进无效,有完整源码测试 谢谢
源码下载地址
http://pan.baidu.com/share/link?shareid=157319&uk=4212471801&third=0
1:我加的剪切功能,点击后,RichTextBox并没有剪切了内容,但是发现是可以粘贴的
2:我要给我的自定义控件添加快捷菜单,但是发现写在Generic里无效(代码里面有),现在是写在XAML控件
3:缩进和减少缩进无效
以上示例可以查看源代码
谢谢

------解决方案--------------------
1.剪切属于内置command,直接使用命令即可;

2.注意Generic中Style的作用域

<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:Suntek.WPF.TControls">
    <Style TargetType="{x:Type local:TIconButton}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:CustomControl1}">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">

                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>


3.比较懒,不想下载慢慢看~~~
------解决方案--------------------