【问题标题】:Hide overflowing portions of textblock and image outside a wpf Button在 wpf 按钮外隐藏文本块和图像的溢出部分
【发布时间】:2017-11-27 18:57:58
【问题描述】:

我有一个 WPF 按钮。此按钮内的 ContentControl 包含其他 UI 元素,如 Textblock、Images 等。当我增加 Textblock 或 Image 等的字体大小时,或者我更改 Textblock 内的文本时,然后部分如果文本、字体大小或图像大小大于此按钮的高度和宽度,有时可以看到文本和图像溢出按钮(即父控件)的高度和宽度。我想隐藏文本的这些溢出部分和图像控件,即仅位于按钮内容控件的高度和宽度边界之外的文本块和图像部分。我该怎么做?

【问题讨论】:

    标签: wpf


    【解决方案1】:

    我能够做到。 我只是将整个 ContentControl 放在 Label 内,就完成了。 即早些时候是这样的:-

    <Button>
       <ContentControl>
           <TextBlock/>
       </ContentControl>
    </Button>
    

    现在我是这样的:-

    <Button>
      <Label>
       <ContentControl>
           <TextBlock1/>
            <TextBock2/>
              .
              .
              .
           <Image1/>
           <Image2/>
       </ContentControl>
      </Label>
    </Button>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-12-20
      • 2018-08-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-21
      相关资源
      最近更新 更多