Skip to content

Commit

Permalink
Fix save size table errors
Browse files Browse the repository at this point in the history
  • Loading branch information
SergeyNefyodov committed Jul 7, 2024
1 parent 451835a commit 7933611
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
16 changes: 14 additions & 2 deletions source/RevitLookup/Views/Dialogs/FamilySizeTableEditDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,32 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:dialogs="clr-namespace:RevitLookup.ViewModels.Dialogs"
xmlns:markup="clr-namespace:RevitLookup.Views.Markup"
xmlns:rl="http://revitlookup.com/xaml"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance dialogs:FamilySizeTableEditDialogViewModel}">
<Grid.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<markup:MenusDictionary />
<rl:ControlsDictionary/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Grid.Resources>
<DataGrid
x:Name="SizeTable"
IsReadOnly="False"
CanUserAddRows="False"
HeadersVisibility="Column"
CanUserReorderColumns="False"
ItemsSource="{Binding}" />
ItemsSource="{Binding}">
<DataGrid.RowStyle>
<!-- ReSharper disable once Xaml.StaticResourceNotResolved -->
<Style
TargetType="DataGridRow"
BasedOn="{StaticResource DefaultDataGridRowStyle}">
<EventSetter
Event="MouseRightButtonDown"
Handler="OnRightClick" />
</Style>
</DataGrid.RowStyle>
</DataGrid>
</Grid>
16 changes: 4 additions & 12 deletions source/RevitLookup/Views/Dialogs/FamilySizeTableEditDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,14 @@ public sealed partial class FamilySizeTableEditDialog
private readonly FamilySizeTableEditDialogViewModel _viewModel;
private readonly bool _isEditable;

public FamilySizeTableEditDialog(IServiceProvider serviceProvider, Document document,FamilySizeTableManager manager, string tableName)
public FamilySizeTableEditDialog(IServiceProvider serviceProvider, Document document, FamilySizeTableManager manager, string tableName)
{
_isEditable = true;
_serviceProvider = serviceProvider;
_viewModel = new FamilySizeTableEditDialogViewModel(document, manager, tableName);

DataContext = _viewModel;
InitializeComponent();

SizeTable.LoadingRow += OnGridRowLoading;
}

public FamilySizeTableEditDialog(IServiceProvider serviceProvider, Document document, FamilySizeTable table)
Expand Down Expand Up @@ -77,20 +75,14 @@ public async Task ShowAsync()
_viewModel.SaveData();
}
}

private void OnGridRowLoading(object sender, DataGridRowEventArgs args)
{
var row = args.Row;
row.Loaded += OnGridRowLoaded;
}

private void OnGridRowLoaded(object sender, RoutedEventArgs args)

private void OnRightClick(object sender, RoutedEventArgs routedEventArgs)
{
var element = (FrameworkElement) sender;
var context = (DataRowView) element.DataContext;
CreateGridRowContextMenu(context.Row, element);
}

private void CreateGridRowContextMenu(DataRow dataRow, FrameworkElement dataGridRow)
{
var contextMenu = new ContextMenu
Expand Down

0 comments on commit 7933611

Please sign in to comment.