我有一個控制元件,我想在其中添加 CharacterCasing,因為默認情況下它不支持它。
我添加了一個名為“CharacterCasing”的自定義依賴屬性。現在,當我在 xaml 中使用它時,我希望擁有與普通 TextBox 中一樣的選項:

任何想法如何在依賴屬性中實作建議串列?
這是我在 xaml 中的代碼:
<TestControl:APTextBox CharacterCasing="UpperCase" Text="{Binding AktuelleZeile.LKR, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnDataErrors=True}">
這是依賴屬性:
public static readonly DependencyProperty CharacterCasingProperty =
DependencyProperty.Register(name: "CharacterCasing",
propertyType: typeof(string),
ownerType: typeof(APTextBox),
typeMetadata: new PropertyMetadata("Normal"));
public string CharacterCasing
{
get { return (string)this.GetValue(CharacterCasingProperty); }
set { this.SetValue(CharacterCasingProperty, value); }
}
uj5u.com熱心網友回復:
因為您將其定義為字串。使用 CharacterCasing 或您要使用的列舉型別更改字串。
public static readonly DependencyProperty CharacterCasingProperty =
DependencyProperty.Register(name: "CharacterCasing",
propertyType: typeof(CharacterCasing),
ownerType: typeof(APTextBox),
typeMetadata: new PropertyMetadata(CharacterCasing.Normal));
public CharacterCasing CharacterCasing
{
get { return (CharacterCasing)this.GetValue(CharacterCasingProperty); }
set { this.SetValue(CharacterCasingProperty, value); }
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/422335.html
標籤:
上一篇:是否可以在部分視窗的WPF中具有透明的丙烯酸模糊效果?
下一篇:依賴屬性更改時元素系結不更新
