if (items != null)
private void seedListView()
{
//Define
var data = new[]
{
new []{"Lollipop", "392", "0.2", "0"},
new []{"KitKat", "518", "26.0", "7"},
new []{"Ice cream sandwich", "237", "9.0", "4.3"},
new []{"Jelly Bean", "375", "0.0", "0.0"},
new []{"Honeycomb", "408", "3.2", "6.5"}
};
//Add
foreach (string[] version in data)
{
var item = new ListViewItem(version);
materialListView1.Items.Add(item);
}
}
public class ViewLocationExpander: IViewLocationExpander {
/// <summary>
/// Used to specify the locations that the view engine should search to
/// locate views.
/// </summary>
/// <param name="context"></param>
/// <param name="viewLocations"></param>
/// <returns></returns>
public IEnumerable<string> ExpandViewLocations(ViewLocationExpanderContext context, IEnumerable<string> viewLocations) {
//{2} is area, {1} is controller,{0} is the action
string[] locations = new string[] { "/Views/{2}/{1}/{0}.cshtml"};
return locations.Union(viewLocations); //Add mvc default locations after ours
}
public void PopulateValues(ViewLocationExpanderContext context) {
context.Values["customviewlocation"] = nameof(ViewLocationExpander);
}
}
services.Configure<RazorViewEngineOptions>(options => {
options.ViewLocationExpanders.Add(new ViewLocationExpander());
});
public void OnGetTest()
<a asp-page-handler="test" >test</a>