我有一些用戶控件多邊形,我要的顏色:我怎麼能看到設計時默認的DependencyProperty值當我使用綁定
<LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
<GradientStop Color="{Binding Color}" Offset="0"/>
<GradientStop Color="{Binding SecondaryColor}" Offset="0.5"/>
<GradientStop Color="{Binding Color}" Offset="1"/>
</LinearGradientBrush>
這是我的DataContext:
<DataContext="{Binding RelativeSource={RelativeSource Self}}">
這是我用默認值依賴屬性在PropertyMetadata
定義:
[Category("Silo - appearance")]
public Color Color
{
get { return (Color)GetValue(ColorProperty); }
set { SetValue(ColorProperty, value); }
}
public static readonly DependencyProperty ColorProperty =
DependencyProperty.Register("Color", typeof(Color), typeof(Silo),
new PropertyMetadata((Color)Color.FromArgb(255,0x27, 0x77, 0x9E)));
我Polygon
這裏我把這個LinearGradientBrush
在UserControl
設計時透明。
我試圖重建解決方案,但沒有任何區別。
爲什麼我的默認值不適用於設計時間?
我該怎麼做才能看到(在設計時間)在
PropertyMetadata
中定義的默認顏色?
我所知道的唯一的辦法就是把依賴屬性中基類然後從該基類繼承你的控制。然後它會在設計師工作。不幸的是,我不完全清楚爲什麼。 – Evk
我認爲如何(和何時)綁定評估在這方面扮演着重要角色...... – Kamil
如果您將屬性放在父類中,它是否也適用於您? – Evk