如何UserControl的字段值绑定到视图模型的财产。
我有1 AutoCompleteComboBox,这是绑定到IEnumerablelt; stringgt;现在在AutoCompleteTextBox输入的文本应绑定到一个ViewModel财产。但它分配空值。
以下是代码:
AutoCompleteComboBox.xaml文件代码如下:
<UserControl x:Class="EET.UI.Controls.UserControls.AutoCompleteComboBox"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:contro="clr-namespace=EET.MDM.UI.Modules"
Panel.ZIndex="10">
<Canvas>
<TextBox x:Name="autoTextBox"
Height="25" MinWidth="150"
Margin="0,0,10,0" TextWrapping="NoWrap" >
</TextBox>
<ListBox x:Name="suggestionListBox"
SelectionChanged="suggestionListBox_SelectionChanged"
Background="LightYellow"
Visibility="Collapsed"
MinWidth="150"
Margin="0,25,0,-25"/>
有以下MyTestPage.xaml文件使用以上AutoCompleteComboBox.xaml UserControl的代码:
{C}
这里的"StrParentCounterParties"是IEnumerable集合。|光辉传奇