|
@using Syncfusion.Blazor.DropDowns
@using Syncfusion.Blazor.Buttons
<div class="col-lg-12 control-section">
<div id="listbox-control">
<SfListBox @ref="ListBoxObj" Value=@Value DataSource="@Data" TValue="string[]" TItem="DataValues"></SfListBox>
<SfButton Content="@Content" @onclick="OnClick"></SfButton>
</div>
</div>
<style>
#listbox-control {
width: 25%;
margin: auto;
}
@@media screen and (max-width: 590px) {
#listbox-control {
width: 100%;
}
}
</style>
@code{
public SfListBox<string[], DataValues> ListBoxObj;
public string Content = "Get Value";
public string[] Value = new string[] { "Hennessey Venom" };
public List<DataValues> Data = new List<DataValues>
{
new DataValues{ text = "Hennessey Venom", id = "list-01" },
new DataValues{ text = "Bugatti Chiron", id = "list-02" },
new DataValues{ text = "Bugatti Veyron Super Sport", id = "list-03" },
new DataValues{ text = "SSC Ultimate Aero", id = "list-04" },
new DataValues{ text = "Koenigsegg CCR", id = "list-05" },
new DataValues{ text = "McLaren F1", id = "list-06" },
new DataValues{ text = "Aston Martin One- 77", id = "list-07" },
new DataValues{ text = "Jaguar XJ220", id = "list-08" },
new DataValues{ text = "McLaren P1", id = "list-09" },
new DataValues{ text = "Ferrari LaFerrari", id = "list-10" }
};
public class DataValues
{
public string text { get; set; }
public string id { get; set; }
}
public void OnClick(MouseEventArgs args)
{
string[] values = ListBoxObj.Value;
}
} |