zoukankan      html  css  js  c++  java
  • WPF RichTextBox的Template Style问题

        在项目中实际设计中需要改变RichTextBox的UI呈现,今天在Coding的过程中发现在RichTextBox的ControlTemplate中使用ContentPresenter并不能将RichTextBox的Content呈现出来。

         查看MSDN,参见http://msdn.microsoft.com/en-us/library/ff457769(v=vs.95).aspx

         原来要将Content的呈现只需将PART_ContentHost写入Template即可。

         代码如下:

        <Grid>
            <RichTextBox>
                <RichTextBox.Document>
                    <FlowDocument Background="AntiqueWhite">
                        <Paragraph>
                            a no space anymore between it and the second paragraph?
                        </Paragraph>
                    </FlowDocument>
                </RichTextBox.Document>
                <RichTextBox.Template>
                    <ControlTemplate>
                        <DockPanel LastChildFill="True">
                            <Label Background="Red" Width="50" HorizontalAlignment="Left"></Label>
                            <ScrollViewer Margin="2"
                                        x:Name="PART_ContentHost"
                                        VerticalAlignment="Stretch"
                                        HorizontalAlignment="Stretch"
                                        BorderBrush="Transparent"
                                        Background="Transparent"/>
                        </DockPanel>
                    </ControlTemplate>
                </RichTextBox.Template>
            </RichTextBox>
        </Grid>

        效果图:

          

          转载时,请注明本文来源:www.cnblogs.com/tmywu

      

      作者: 淘米部落

          mail:tommywu23@126.com

  • 相关阅读:
    连续两天写论文
    既然杂事比较多,索性统统处理一下
    Power symbol
    不要被一些无谓的事情烦扰
    今天提前回去吧,整理一下,为下周做好准备。
    天气暖和了,我却感冒了
    每天回想一下,今天到底完成了什么
    opensue12.1硬盘升级安装12.2问题解决
    IPmsg(飞鸽传书)协议翻译
    关于交叉验证和过拟合
  • 原文地址:https://www.cnblogs.com/tmywu/p/2625694.html
Copyright © 2011-2022 走看看