2013-09-04 2 views
0

Обычно я использую атрибут description для пользовательских свойств в пользовательском управлении WPF, как показано ниже.Как показать описания свойств в Windows Store App User Control?

 [Category("Features"), Description("You can setup image width ratio in double type")] 
    public double ImageWidthRatio 
    { 
     get { return (double)GetValue(ImageWidthRatioProperty); } 
     set { SetValue(ImageWidthRatioProperty, value); } 
    } 

    // Using a DependencyProperty as the backing store for ImageWidthRatioProperty. This enables animation, styling, binding, etc... 
    public static readonly DependencyProperty ImageWidthRatioProperty = 
     DependencyProperty.Register("ImageWidthRatio", typeof(double), typeof(TheControl), new UIPropertyMetadata(1.0)); 

Линия [Category("Features"), Description("You can setup image width ratio")] дает описания с группами в окне свойств.

Но, это пользовательский контроль приложений в Windows Store. Он говорит: System.ComponentModel.DesriptionAttribute.

Как показать мои описания свойств в окне свойств в WinRT?

ответ

0

Добавить этот вспомогательный класс

using System; 

namespace System.ComponentModel 
{ 
    [AttributeUsage(AttributeTargets.All)] 
    public class DescriptionAttribute : Attribute 
    { 
     public DescriptionAttribute(string description) 
     { 
      Description = description; 
     } 

     public string Description { get; private set; } 

     public override bool Equals(object obj) 
     { 
      if (obj == this) 
       return true; 

      var other = obj as DescriptionAttribute; 
      return other != null && other.Description == Description; 
     } 

     public override int GetHashCode() 
     { 
      return Description.GetHashCode(); 
     } 
    } 
} 
+0

// спасибо за быстрый ответ. ваши коды фактически создают атрибут 'Description', но он не предоставляет информацию в панели свойств как WPF. поэтому мы можем судить, что нет возможности «показать описание в окне свойств», правильно? – Youngjae