I would like to prevent the Drawer from collapsing when an item from the navigation is clicked and switch between the collapsed and expanded state by the click of a button.
<TelerikDrawer Expanded="@DrawerExpanded"
ExpandedChanged="@DrawerExpandedChanged"
Data="Data"
Mode="@DrawerMode.Push"
MiniMode="true"
@bind-SelectedItem="@SelectedItem">
<DrawerContent>
<TelerikButton OnClick="@ToggleDrawer" Icon="@SvgIcon.Menu" />
<p>@SelectedItem?.Text</p>
</DrawerContent>
</TelerikDrawer>
@code {
public DrawerItem SelectedItem { get; set; }
public bool DrawerExpanded { get; set; } = true;
public IEnumerable<DrawerItem> Data { get; set; } =
new List<DrawerItem>
{
new DrawerItem { Text = "Inbox", Icon = SvgIcon.Inbox },
new DrawerItem { Text = "Notifications", Icon = SvgIcon.Bell },
new DrawerItem { Text = "Calendar", Icon = SvgIcon.Calendar },
new DrawerItem { Text = "Attachments", Icon = SvgIcon.EnvelopeLink },
new DrawerItem { Text = "Favourites", Icon = SvgIcon.StarOutline }
};
private void ToggleDrawer()
{
DrawerExpanded = !DrawerExpanded;
}
private void DrawerExpandedChanged(bool newExpanded)
{
// Do not modify the DrawerExpanded value here.
}
public class DrawerItem
{
public string Text { get; set; }
public ISvgIcon Icon { get; set; }
}
}