2011-04-21 25 views
3

問:性能指示控制及其家長

最近,我問了一下關於設置(Visible)屬性,當我把它設置爲true的問題,我驚訝於追蹤將其設定爲true.that後其價值仍然是虛假的。答案是我一個驚喜:

- "The Visible property has a special 
    property: when you read the value it 
    not only reports on the control 
    itself but also on it's parent. The 
    value you get is the "real" 
    visibility." 

我的問題是:有沒有財產,你像(Visible)相同的方法的行爲之前見面嗎?以及我們應該如何以最佳方式使用它們?

+0

你是什麼意思..不明確 – V4Vendetta 2011-04-21 11:40:27

+0

http://stackoverflow.com/questions/5729069/property-has-the-same-value-after-setting-it 我想所有屬性表現得像(' Visible')。 – 2011-04-21 11:42:07

回答

1

嗯,我不知道,嘗試此查詢:

var lst =Control.Properties.Where(p => HasSimilarBehaviourToVisibleProperty(p)); 

你只需要編寫HasBehaviourLikeVisibleProperty方法。

注意:您可能需要反射才能獲取所有屬性。 (看看here獲取物業)

1

啓用可能是這種方式的一個屬性。