File tree Expand file tree Collapse file tree
src/SharpFM/Schema/Editor Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2525 <Button Grid.Column=" 2"
2626 Margin =" 8,0,4,0"
2727 Content =" + Add Field"
28- x : Name = " addFieldButton " />
28+ Command = " {Binding AddFieldCommand} " />
2929 <Button Grid.Column=" 3"
3030 Content =" Remove"
31- x : Name = " removeFieldButton " />
31+ Command = " {Binding RemoveFieldCommand} " />
3232 <Button Grid.Column=" 4"
3333 Margin =" 8,0,0,0"
3434 Content =" Edit Calculation..."
35- x : Name = " editCalcButton " />
35+ Command = " {Binding EditCalculationCommand} " />
3636 </Grid >
3737 </Border >
3838
Original file line number Diff line number Diff line change 11using System ;
22using Avalonia . Controls ;
33using Avalonia . Input ;
4- using Avalonia . Interactivity ;
54using SharpFM . Schema . Model ;
65
76namespace SharpFM . Schema . Editor ;
@@ -14,23 +13,12 @@ public partial class TableEditorControl : UserControl
1413 public TableEditorControl ( )
1514 {
1615 InitializeComponent ( ) ;
17-
18- var addBtn = this . FindControl < Button > ( "addFieldButton" ) ;
19- var removeBtn = this . FindControl < Button > ( "removeFieldButton" ) ;
20- var calcBtn = this . FindControl < Button > ( "editCalcButton" ) ;
21-
22- if ( addBtn != null ) addBtn . Click += ( _ , _ ) => GetVm ( ) ? . AddField ( ) ;
23- if ( removeBtn != null ) removeBtn . Click += ( _ , _ ) => GetVm ( ) ? . RemoveSelectedField ( ) ;
24- if ( calcBtn != null ) calcBtn . Click += ( _ , _ ) => GetVm ( ) ? . OpenCalculationEditor ( ) ;
25-
2616 KeyDown += OnKeyDown ;
2717 }
2818
29- private TableEditorViewModel ? GetVm ( ) => DataContext as TableEditorViewModel ;
30-
3119 private void OnKeyDown ( object ? sender , KeyEventArgs e )
3220 {
33- if ( e . Key == Key . Delete && GetVm ( ) is { } vm )
21+ if ( e . Key == Key . Delete && DataContext is TableEditorViewModel vm )
3422 {
3523 vm . RemoveSelectedField ( ) ;
3624 e . Handled = true ;
You can’t perform that action at this time.
0 commit comments