WPF binden an die Inhaltseigenschaft von Content Control
Posted: 28 Jan 2025, 06:02
Wie kann ich mich an die Inhaltseigenschaft von Inhaltskontrolle binden? public class CustomControl
{
// Dependency Properties
public int MyProperty
{
get { return (int)GetValue(MyPropertyProperty); }
set { SetValue(MyPropertyProperty, value); }
}
// Using a DependencyProperty as the backing store for MyProperty. This enables animation, styling, binding, etc...
public static readonly DependencyProperty MyPropertyProperty =
DependencyProperty.Register("MyProperty", typeof(int), typeof(MainViewModel), new PropertyMetadata(0));
}
< /code>
In ViewModel habe ich eine Eigenschaft vom Typ dieser benutzerdefinierten Steuerung erstellt: < /p>
public CustomControl CustomControl { get; set; }
< /code>
In der Ansicht binden ich diese Eigenschaft an die Inhaltskontrolle: < /p>
< /code>
Wie kann ich nun an die Inhaltseigenschaft von Content Control binden? < /p>
{
// Dependency Properties
public int MyProperty
{
get { return (int)GetValue(MyPropertyProperty); }
set { SetValue(MyPropertyProperty, value); }
}
// Using a DependencyProperty as the backing store for MyProperty. This enables animation, styling, binding, etc...
public static readonly DependencyProperty MyPropertyProperty =
DependencyProperty.Register("MyProperty", typeof(int), typeof(MainViewModel), new PropertyMetadata(0));
}
< /code>
In ViewModel habe ich eine Eigenschaft vom Typ dieser benutzerdefinierten Steuerung erstellt: < /p>
public CustomControl CustomControl { get; set; }
< /code>
In der Ansicht binden ich diese Eigenschaft an die Inhaltskontrolle: < /p>
< /code>
Wie kann ich nun an die Inhaltseigenschaft von Content Control binden? < /p>