【问题标题】:Silverlight / Blend - How to create FontSize dependency property with dropdown listSilverlight / Blend - 如何使用下拉列表创建 FontSize 依赖属性
【发布时间】:2011-06-28 10:51:24
【问题描述】:

在我的自定义行为中,我创建了以下依赖属性:

public double FontSize
{
    get { return (double)GetValue(FontSizeProperty); }
    set { SetValue(FontSizeProperty, value); }
}

public static readonly DependencyProperty FontSizeProperty = DependencyProperty.Register(
        "FontSize",
        typeof (double),
        typeof (CustomBehavior),
        new PropertyMetadata(11, null));
  1. 如何绑定值,因为在 Blend 绑定按钮被禁用。
  2. 如何在文本类别中显示标准字体大小的下拉列表,例如 Textblock 的下拉列表

【问题讨论】:

  • 这是一个派生自System.Windows.Interactivity.Behaviour的类?
  • 您在此期间解决了这个问题吗?我们有完全相同的要求。非常感谢,迈克尔
  • 不行,还是找不到答案(((
  • 你们使用的是哪个版本的 Silverlight?

标签: silverlight drop-down-menu dependency-properties font-size blend


【解决方案1】:

我不知道这是否有帮助,或者您是否已经找到了答案,但我在这里...

您问题的第 2 部分:

你首先声明一个项目的枚举:

public enum DDItems
{
    Default = 0,
    Item1 = 1,
    Item2 = 2,
    Item3 = 3,
    Item4 = 4,
    Item5 = 5
}

然后你就有了这样的依赖属性:

    public DDItems TextSearchModeABC
    {
        get
        {
            return (DDItems)GetValue(MyItemProperty);
        }
        set
        {
            SetValue(MyItemProperty, value);
        }
    }

    public static readonly DependencyProperty MyItemProperty =
        DependencyProperty.Register("MyItemProperty", typeof(DDItems), typeof(MyControlType), new PropertyMetadata(null));

希望这会有所帮助。

【讨论】:

    猜你喜欢
    • 2019-10-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-23
    • 2020-01-16
    • 1970-01-01
    • 2017-07-19
    • 2018-06-17
    相关资源
    最近更新 更多