Oldukça emin bir şekilde yanlış bir şey yapıyorum, ancak bunu anlayamıyorum.WPF Bağlama Çalışmıyor
Bir sınıfın etrafında basit bir sarıcı oluşturdum ve bağımlılık özelliği ekledim, böylece bağlanabilirdim. Ancak, bağlanma hiçbir hata vermez, ancak hiçbir şey yapmaz.
Öğeleri basitleştirmek için, sınıfı TextBox olarak değiştirdim ve aynı sonuçları aldım.
public class TextEditor : TextBox
{
#region Public Properties
#region EditorText
/// <summary>
/// Gets or sets the text of the editor
/// </summary>
public string EditorText
{
get
{
return (string)GetValue(EditorTextProperty);
}
set
{
//if (ValidateEditorText(value) == false) return;
if (EditorText != value)
{
SetValue(EditorTextProperty, value);
base.Text = value;
//if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("EditorText"));
}
}
}
public static readonly DependencyProperty EditorTextProperty =
DependencyProperty.Register("EditorText", typeof(string), typeof(TextEditor));
#endregion
#endregion
#region Constructors
public TextEditor()
{
//Attach to the text changed event
//TextChanged += new EventHandler(TextEditor_TextChanged);
}
#endregion
#region Event Handlers
private void TextEditor_TextChanged(object sender, EventArgs e)
{
EditorText = base.Text;
}
#endregion
}
Ben ilk sonuçlar verir aşağıdaki XAML çalıştırmak
, ama ikinci bir (EditorText) bile EditorText özelliği isabet etmez.<local:TextEditor IsReadOnly="True" Text="{Binding Path=RuleValue, Mode=TwoWay}" WordWrap="True" />
<local:TextEditor IsReadOnly="True" EditorText="{Binding Path=RuleValue, Mode=TwoWay}" WordWrap="True" />
+1, bana onu dövdün :) –
Tek kelimeyle harika. Bunu hiç bir yerde belgelemedim, ama harika çalışıyor. Teşekkürler. – Telavian