简体   繁体   中英

How to set default value for a combobox in lightswitch

I've created a ComboBox for my search screen and it works as expected.

I'am using code for the binding:

partial void SearchStatusTest_Created()
    {
        IContentItemProxy comboControl = this.FindControl("Status");

        comboControl.SetBinding(
        System.Windows.Controls.ComboBox.ItemsSourceProperty,
        "Screen.ManagerStatusFilter",
        System.Windows.Data.BindingMode.TwoWay);

        comboControl.SetBinding(
        System.Windows.Controls.ComboBox.SelectedItemProperty,
        "Screen.Status",
        System.Windows.Data.BindingMode.TwoWay);

        this.Status = this.DataWorkspace.ProjectDeck2Data.Statuses_SingleOrDefault(2);

    }

Trying to set the default value the following:

this.Status = this.DataWorkspace.ProjectDeck2Data.Statuses_SingleOrDefault(2):

Notice that it does work, but still couldn't see the default value in the ComboBox on the screen.

Try creating a riaservice. In this riaservice you can cast your query to a List and add some options.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM