我的autocompletebox有以下代码,我正在尝试做我认为相当简单的事情。我有一个用户和用户ID列表。我希望用户键入“jim”并查看“jim”但将我的值绑定到user_id,如“3”,然后当表单重新加载时将值绑定到“3”但显示“jim”
这可能吗?如果是这样,我在下面做错了什么?
提前致谢
Public Class ADUsersConverter
Implements IValueConverter
Public Function Convert(value As Object, targetType As Type, parameter As Object, culture As System.Globalization.CultureInfo) As Object Implements IValueConverter.Convert
If value Is Nothing Then Return Nothing
Dim u As SER_User.usp_Get_All_Active_usersResult = TryCast(value, SER_User.usp_Get_All_Active_usersResult)
If Not u Is Nothing Then Return u.Display_Name
End Function
Public Function ConvertBack(value As Object, targetType As Type, parameter As Object, culture As System.Globalization.CultureInfo) As Object Implements IValueConverter.ConvertBack
Return Nothing
End Function
结束班
“XAML
<sdk:AutoCompleteBox Name="acb_reviewedby" HorizontalAlignment="Stretch" Grid.Column="6" Grid.Row="3" Margin="5" Text="{Binding Path=Reviewed_By, Mode=TwoWay}" MinimumPopulateDelay="500" ValueMemberBinding="{Binding Converter={StaticResource ADUsersConvert}}">
<sdk:AutoCompleteBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Display_Name}"></TextBlock>
</DataTemplate>
</sdk:AutoCompleteBox.ItemTemplate>
</sdk:AutoCompleteBox>
答案 0 :(得分:0)
我建议实现此行为的最佳方法是为EventTrigger
事件添加Populating
并手动选择所需的用户。