

|
<div class="col-lg-12 control-section">
<div id="listbox-control">
<h4>Select your favorite car:</h4>
<SfListBox DataSource="@Data" TValue="string[]" TItem="ListData" AllowDragAndDrop="true">
<ListBoxEvents TItem="ListData" TValue="string[]" Dropped="OnDropped"></ListBoxEvents>
<ListBoxFieldSettings Text="text" Value="id"></ListBoxFieldSettings>
</SfListBox>
</div>
</div>
<br />
<br />
<SfButton CssClass="e-success" @onclick="PropertyBinding">Add</SfButton>
@code
{
public ObservableCollection<ListData> Data { get; set; }
public class ListData
{
public string id { get; set; }
public string text { get; set; }
public static ObservableCollection<ListData> getListData()
{
ObservableCollection<ListData> Data = new ObservableCollection<ListData>();
Data.Add(new ListData() { text = "Hennessey Venom", id = "list-01" });
Data.Add(new ListData() { text = "Bugatti Chiron", id = "list-02" });
Data.Add(new ListData() { text = "Bugatti Veyron Super Sport", id = "list-03" });
Data.Add(new ListData() { text = "SSC Ultimate Aero", id = "list-04" });
Data.Add(new ListData() { text = "Koenigsegg CCR", id = "list-05" });
Data.Add(new ListData() { text = "McLaren F1", id = "list-06" });
Data.Add(new ListData() { text = "Aston Martin One- 77", id = "list-07" });
Data.Add(new ListData() { text = "Jaguar XJ220", id = "list-08" });
Data.Add(new ListData() { text = "McLaren P1", id = "list-09" });
Data.Add(new ListData() { text = "Ferrari LaFerrari", id = "list-10" });
return Data;
}
}
protected override void OnInitialized()
{
this.Data = ListData.getListData();
}
private void PropertyBinding()
{
this.Data.Add(new ListData() { id = "c", text = "RAKKI" });
}
} |