在UserControl的依赖项属性内的设计时选择内容

时间:2014-01-24 18:49:47

标签: c# wpf xaml user-controls dependency-properties

我有一个用户控件,我用它来控制项目中所有页面的内容。它允许我轻松控制页面的页眉和页脚,并具有匹配的样式等。我在Visual Studio 2010中设计了这一切,并使用内置的XAML Designer来布局我的所有页面。我以前能够单击设计图面上MainContent依赖项属性内的对象,并让它突出显示该控件的XAML定义。在我升级到VS2012后,有些东西坏了,现在只有当我点击MainContent Grid中的任何内容时它才会突出显示flxv:MasterPageCustomControl。我已经尝试过多次修复并与它一起生活了一年多了......任何人都可以帮助我吗?我不确定要提供多少信息。

<flxv:MasterPageCustomControl HeaderTitle="Display Menu" 
                              HeaderDescription="Modify the properties and content of this display"
                              HeaderIcon="/SFD.Client;component/Images/32x32/plasma-tv.png"
                              FooterContentTemplate="{StaticResource FooterContentTemplate}">
    <flxv:MasterPageCustomControl.MainContent>

        <Grid>
            <Button/>
        </Grid>

    </flxv:MasterPageCustomControl.MainContent>
</flxv:MasterPageCustomControl>

用户控制代码:

public partial class MasterPageCustomControl : System.Windows.Controls.UserControl
{
    #region Fields

    public static readonly DependencyProperty FooterContentTemplateProperty;
    public static readonly DependencyProperty HeaderDescriptionProperty;
    public static readonly DependencyProperty HeaderIconProperty;
    public static readonly DependencyProperty HeaderTitleProperty;
    public static readonly DependencyProperty MainContentProperty;

    #endregion Fields

    #region Properties

    public DataTemplate FooterContentTemplate
    {
        get { return (DataTemplate)GetValue(FooterContentTemplateProperty); }
        set { SetValue(FooterContentTemplateProperty, value); }
    }

    public string HeaderDescription
    {
        get { return (string)GetValue(HeaderDescriptionProperty); }
        set { SetValue(HeaderDescriptionProperty, value); }
    }

    public string HeaderIcon
    {
        get { return (string)GetValue(HeaderIconProperty); }
        set { SetValue(HeaderIconProperty, value); }
    }

    public string HeaderTitle
    {
        get { return (string)GetValue(HeaderTitleProperty); }
        set { SetValue(HeaderTitleProperty, value); }
    }
    public object MainContent
    {
        get { return (object)GetValue(MainContentProperty); }
        set { SetValue(MainContentProperty, value); }
    }

    #endregion Properties

    #region Constructors

    static MasterPageCustomControl()
    {
        FooterContentTemplateProperty = DependencyProperty.Register(
            "FooterContentTemplate",
            typeof(DataTemplate),
            typeof(MasterPageCustomControl));

        HeaderDescriptionProperty = DependencyProperty.Register(
            "HeaderDescription",
            typeof(string),
            typeof(MasterPageCustomControl));

        HeaderIconProperty = DependencyProperty.Register(
            "HeaderIcon",
            typeof(string),
            typeof(MasterPageCustomControl));

        HeaderTitleProperty = DependencyProperty.Register(
            "HeaderTitle",
            typeof(string),
            typeof(MasterPageCustomControl));

        HeaderWorkstationVisiblity = DependencyProperty.Register(
            "HeaderWorkstationVisiblity",
            typeof(Visibility),
            typeof(MasterPageCustomControl),
            new PropertyMetadata(Visibility.Visible));

        MainContentProperty = DependencyProperty.Register(
            "MainContent",
            typeof(object),
            typeof(MasterPageCustomControl));

        // ---------------------------------------

        DefaultStyleKeyProperty.OverrideMetadata(typeof(MasterPageCustomControl), new FrameworkPropertyMetadata(typeof(MasterPageCustomControl)));
    }

0 个答案:

没有答案