Search code examples
silverlightservicelist.selectedvalue

silverlight 4: setting selectedvaluepath, how do i extract it?>


im completely new to the wcf service things so im a bit lost on the approach here. I have an operation in the service called GetHoldsJoined. The listbox im binding to is called lbxOpenHolds. I am able to set the result as an itemsource with the following:

public frmHoldsDashBoard()
        {
            InitializeComponent();

            dbServiceClient db = new dbServiceClient();
            db.GetHoldsJoinedCompleted +=new EventHandler<GetHoldsJoinedCompletedEventArgs>(db_GetHoldsJoinedCompleted);
            db.GetHoldsJoinedAsync();

        }

        private void db_GetHoldsJoinedCompleted(object sender, GetHoldsJoinedCompletedEventArgs e)
        {
            lbxOpenHolds.ItemsSource = e.Result;
        }

but what I want to do is set the selectedvaluepath to an attribute in one of the result list items. The result is a List collection. There is an attribute in each one of the list objects called a.HoldID, it is composite. I want this to be the selectedvalue member. How do I unbox this from GetHoldsCompletedEventArgs ?? Or is there some other way to do this?

Sorry if the question is asked kind of scatterbrained, I really didn't know how else to explain it.


Solution

  • What about something like this:

    lbxOpenHolds.SelectedValuePath = "HoldID";
    

    This should go right after setting the ItemsSource on lbxOpenHolds