【问题标题】:How to create a RadioButton without a content (uwp,xaml,c#)如何创建没有内容的 RadioButton (uwp,xaml,c#)
【发布时间】:2018-01-13 15:14:25
【问题描述】:

我想创建一个只有一个单选按钮而没有内容的自定义控件。有没有可以取消/删除内容部分的功能,我应该使用模板化控件来修改模板吗(我可以这样做吗?)。

【问题讨论】:

  • 如果您标记了您正在使用的技术(通过标记),那么有人可能会帮助您。请edit您的问题并添加适当的标签
  • 为什么需要创建自定义控件来执行此操作?通过 xaml 添加 RadioButton 而不在 Content 属性中添加任何内容会产生所需的结果(只是圆形 Radiobutton 部分,没有文本)

标签: c# xaml uwp radio-button


【解决方案1】:

创建没有内容的RadioButton 非常简单:

<RadioButton />

如果要彻底删除内容,可以修改默认样式(见default style here):

...  
    </Grid>
    <!-- comment out or delete the Content Presenter -->
    <!-- <ContentPresenter x:Name="ContentPresenter"
                      Content="{TemplateBinding Content}"
                      ContentTransitions="{TemplateBinding ContentTransitions}"
                      ContentTemplate="{TemplateBinding ContentTemplate}"
                      Margin="{TemplateBinding Padding}"
                      HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                      VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                      Grid.Column="1"
                      AutomationProperties.AccessibilityView="Raw"
                      TextWrapping="Wrap" /> -->
  </Grid>
...

【讨论】:

    猜你喜欢
    • 2017-07-28
    • 2016-12-30
    • 2019-01-27
    • 2016-10-20
    • 2017-06-08
    • 2019-05-08
    • 1970-01-01
    • 1970-01-01
    • 2019-01-19
    相关资源
    最近更新 更多