讓我給你提供更多的細節。情況是我正在處理一個用戶控件,並且我有一個依賴對象接收一個枚舉。根據值,必須顯示一個按鈕。自XAML以來,我怎樣才能顯示一個按鈕?
我的意思是:
public enum Entradas
{
Entero, Decimal
}
public partial class TableroUserControl : UserControl
{
public Entradas Entrada
{
get { return (Entradas)GetValue(EntradaProperty); }
set { SetValue(EntradaProperty, value); }
}
public static readonly DependencyProperty EntradaProperty =
DependencyProperty.Register("Entrada", typeof(Entradas), typeof(TableroUserControl));
}
當EntradaProperty接收Entradas.Entero,它必須顯示在用戶的控制按鈕,並把小數時,必須消失的按鈕。雖然,該屬性也必須包含默認值。
我不知道是否必須在EntradaProperty中聲明PropertyMetadata對象或使用IValueConverter。
我該怎麼做?提前致謝。