开发者

Silverlight AutoComplete Box

开发者 https://www.devze.com 2023-04-11 15:48 出处:网络
I have the below code for my autocompletebox and I am trying to do what I think is fairly simple. I have a list of users and user id. I want the user to type in \"jim\" and see \"jim\" but bind my val

I have the below code for my autocompletebox and I am trying to do what I think is fairly simple. I have a list of users and user id. I want the user to type in "jim" and see "jim" but bind my value to the user_id such as "3" then when the form reloads bind the value to "3" but show "jim"

Is this possible and if so what I am doing incorrectly below?

Thanks in advance

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

End Class

'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>
                    &l开发者_如何学编程t;/sdk:AutoCompleteBox>


I suggest that the best way of implementing this behavior is to add EventTrigger for Populating event and manually select needed user.

0

精彩评论

暂无评论...
验证码 换一张
取 消