Add context menu
This commit is contained in:
parent
ba7d890966
commit
eed3d84517
@ -44,6 +44,13 @@
|
||||
<DataTemplate>
|
||||
<Button Padding="0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Click="LiberateButton_Click" ToolTip.Tip="{Binding Liberate.ToolTip}">
|
||||
<Image Stretch="None" Source="{Binding Liberate.Image}" />
|
||||
<Button.ContextMenu>
|
||||
<ContextMenu IsVisible="{Binding !Liberate.IsSeries}">
|
||||
<MenuItem Header="Item 1" Click="ContextMenuItem1_Click" />
|
||||
<MenuItem Header="Item 2" Click="ContextMenuItem2_Click" />
|
||||
<MenuItem Header="Item 3" Click="ContextMenuItem3_Click" />
|
||||
</ContextMenu>
|
||||
</Button.ContextMenu>
|
||||
</Button>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
|
||||
@ -10,6 +10,7 @@ using LibationAvalonia.Dialogs;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Avalonia.Interactivity;
|
||||
|
||||
namespace LibationAvalonia.Views
|
||||
{
|
||||
@ -184,6 +185,22 @@ namespace LibationAvalonia.Views
|
||||
|
||||
#region Button Click Handlers
|
||||
|
||||
public void ContextMenuItem1_Click(object sender, Avalonia.Interactivity.RoutedEventArgs args)
|
||||
{
|
||||
var lbe = getBoundEntry(args.Source);
|
||||
}
|
||||
public void ContextMenuItem2_Click(object sender, Avalonia.Interactivity.RoutedEventArgs args)
|
||||
{
|
||||
var lbe = getBoundEntry(args.Source);
|
||||
}
|
||||
public void ContextMenuItem3_Click(object sender, Avalonia.Interactivity.RoutedEventArgs args)
|
||||
{
|
||||
var lbe = getBoundEntry(args.Source);
|
||||
}
|
||||
|
||||
private static LibraryBookEntry getBoundEntry(IInteractive source)
|
||||
=> (source is IStyledElement se && se.DataContext is LibraryBookEntry lbe ? lbe : null);
|
||||
|
||||
public void LiberateButton_Click(object sender, Avalonia.Interactivity.RoutedEventArgs args)
|
||||
{
|
||||
var button = args.Source as Button;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user