0
[Category("SomeCat")]
[Description("Gets or sets how items are displayed in the ShellListView control.")]
[DefaultValue(View.Details)]
new public View View
{
    get { return base.View; }
    set
    {
        System.Diagnostics.Debug.WriteLine("View");

        if (value != View.LargeIcon)
        {
            //Reset these values because they can only be true if LargeIcon is set.
            ShowExtraLargeIcons = false;
        }

        base.View = value;
    }
}    

private bool m_ShowExtraLargeIcons;

[Category("Appearance")]
[DefaultValue(false)]
public bool ShowExtraLargeIcons
{
    get { return m_ShowExtraLargeIcons; }
    set
    {
        if (m_ShowExtraLargeIcons == value) 
            return;

        System.Diagnostics.Debug.WriteLine("Extra");

        m_ShowExtraLargeIcons = value;

        if (m_ShowExtraLargeIcons)
        // Always set view to LargeIcon if ShowExtraLargeIcons is enabled
            View = View.LargeIcon;
    }
}

我的问题:如果我将 View 设置为 LargeIcons 以外的其他内容(通过 VS 2010 的属性管理器),ShowExtraLargeIcons 属性仍然为 True,尽管它已设置为 False。

如果我将 ShowExtraLargeIcons 设置为 True,则属性 View 将按预期设置为 LargeIcons。

可能有帮助的东西:设置 ShowExtraLargeIcons 后显示调试消息(“View”和“Extra”),在设置 View 后它们不显示(均在设计时设置)。

4

2 回答 2

2

这与依赖属性无关,它只是属性浏览器的行为。

当您在类成员上使用 new 修饰符时,您并没有创建“覆盖”。ListView.View不是虚拟财产。MyListView.View您正在创建一个具有相同签名和名称的全新属性 ( )。

属性浏览器将枚举属性并使用描述符来处理它们。它将看到两个完全不同的属性,要么显示它们,要么任意选择一个。

于 2011-01-24T16:49:29.243 回答
0
new public View

如果未显示跟踪,则看起来您正在编辑某些父对象。并且该 paranet 对象在不影响 m_ShowExtraLargeIcons var 的情况下进行编辑。

于 2011-01-24T16:51:32.860 回答