Skip to content

Commit e93eb71

Browse files
committed
chore(drawer): Added example for preselection of item in Events article
1 parent 81cb062 commit e93eb71

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

components/drawer/events.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,20 @@ The `SelectedItemChanged` event fires every time the user clicks on a new item f
4444
Console.WriteLine($"The user selected {item.Text}");
4545
}
4646
47+
protected override void OnInitialized()
48+
{
49+
//You can preselect an item in the lifecycle methods that the framework provides.
50+
selectedItem = Data.FirstOrDefault();
51+
//Here you can use another LINQ expressions like Where() or else depending on your application needs.
52+
}
53+
4754
public DrawerItem selectedItem { get; set; }
4855
public IEnumerable<DrawerItem> Data { get; set; } =
4956
new List<DrawerItem>
5057
{
5158
new DrawerItem { Text = "Counter", Icon = IconName.Plus},
5259
new DrawerItem { Text = "FetchData", Icon = IconName.GridLayout},
53-
};
60+
};
5461
5562
public class DrawerItem
5663
{

0 commit comments

Comments
 (0)