WPF

2009-12-07 12 views
5

में एक निर्भरता संपत्ति के रूप में enum का उपयोग करते हुए मैं अपने कस्टम नियंत्रण में एक निर्भरता संपत्ति के रूप में enum प्रकार का उपयोग करने का प्रयास करें, लेकिन हमेशा कोई त्रुटि मिलती है:WPF

public enum PriceCategories 
    { 
     First = 1, 
     Second = 2, 
     Third = 3, 
     Fourth = 4, 
     Fifth = 5, 
     Sixth = 6 
    } 
    public static readonly DependencyProperty PriceCatProperty = 
DependencyProperty.Register("PriceCat", typeof(PriceCategories), typeof(CustControl), new PropertyMetadata(PriceCategories.First)); 
}; 

    public PriceCategories PriceCat // here I get an error "Expected class, delegate, enum, interface or struct" 
    { 
     get { return (PriceCategories)GetValue(PriceCatProperty); } 
     set { SetValue(PriceCatProperty, value); } 
    } 

कृपया, देखो। गलती कहां है?

उत्तर

10

आपके डीपी को कक्षा के दायरे में घोषित नहीं किया जा रहा है। ऐसा लगता है कि डीपी घोषणा के बाद आपके पास अतिरिक्त बंद ब्रेस है।

public enum PriceCategories 
{ 
    // ... 
} 
public static readonly DependencyProperty PriceCatProperty = 
    DependencyProperty.Register("PriceCat", typeof(PriceCategories), 
    typeof(CustControl), new PropertyMetadata(PriceCategories.First)); 
}; // <-- this is probably closing the containing class 
+0

ओह, हाँ यह यह ब्रेस है। धन्यवाद! – rem