Home > other >  WPF create user controls how to bind? emergency
WPF create user controls how to bind? emergency

Time:10-07

If I create a user control is called: now DualTextBox
Contains a ComboBox and a textbox


MinHeight="25" IsEditable="True"/& gt;






Now I using the control project,

Could you tell me how to make me a list or array to bind to this ComboBox, want to be able to use when binding DualTextBox. CmbItemSource (not ItemSource)
At the same time, it will be my one variable to bind to the TextBox, want to be able to use when binding DualTextBox. TbText (rather than Text)

CodePudding user response:

Define the corresponding dependency properties, the query WPF dependency properties can,

CodePudding user response:

You should not use UserControl to solve such a demand, a custom control that inherits from the ComboBox, so the collection property you don't have to write their own, and then for the TextBox Text a dependency properties, the last in your custom controls on the control template design you how to put the two control is ok

CodePudding user response:

A custom dependency property, similar to:
Public static readonly DependencyProperty GradeListProperty=DependencyProperty. Register (" GradeList typeof (IList) The typeof (CourseHourDataGrid), new FrameworkPropertyMetadata (null));

Public IList GradeList
{
The get
{
Return (IList) Base. The GetValue (GradeListProperty);
}
Set
{
Base. SetValue (GradeListProperty, value);
}
}
  • Related