Skip to content

Commit a4162aa

Browse files
committed
Update DataGridCheckBoxColumn
1 parent 99de1bf commit a4162aa

File tree

4 files changed

+21
-8
lines changed

4 files changed

+21
-8
lines changed

RevitAddin.CommandBindingTester/Models/BindingModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ public class BindingModel
88
public PostableCommand PostableCommand { get; internal set; }
99
public string Name { get; internal set; }
1010
public uint Id { get; internal set; }
11-
public bool CanHaveBinding { get; internal set; }
12-
public bool HasBinding { get; internal set; }
11+
public bool CanHaveBinding { get; private set; }
12+
public bool HasBinding { get; private set; }
1313

1414
override public string ToString()
1515
{

RevitAddin.CommandBindingTester/Models/CreateBindingModel.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,14 @@ public enum ExecutedCommand
3232
public class CreateBindingModel
3333
{
3434
[AlsoNotifyFor(nameof(Name), nameof(Id))]
35-
public PostableCommand PostableCommand { get; set; }
35+
public PostableCommand PostableCommand { get; set; } = PostableCommand.ThinLines;
3636
public string Name => GetName();
3737
public uint Id => GetId();
3838

3939
public CanExecuteCommand CanExecute { get; set; }
4040
public BeforeExecutedCommand BeforeExecuted { get; set; }
4141
public ExecutedCommand Executed { get; set; }
42+
public bool IsEnabled { get; set; } = false;
4243

4344
private string GetName()
4445
{

RevitAddin.CommandBindingTester/Revit/Commands/CreateCommand.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,17 @@ public Result Execute(ExternalCommandData commandData, ref string message, Eleme
1818
var commands = Enum.GetValues(typeof(PostableCommand))
1919
.OfType<PostableCommand>();
2020

21-
//var models = commands
22-
// .Select(x => Models.CreateBindingModel.Create(x))
23-
// .OrderBy(x => x.Id)
24-
// .ToList();
21+
// Force to Remove all Binding in this AddIn
22+
foreach (var command in commands)
23+
{
24+
try
25+
{
26+
var revitCommandId = RevitCommandId.LookupPostableCommandId(command);
27+
if (revitCommandId.HasBinding)
28+
uiapp.RemoveAddInCommandBinding(revitCommandId);
29+
}
30+
catch { }
31+
}
2532

2633
var viewModel = new CreateBindingViewModel();
2734
var result = viewModel.ShowDialog();

RevitAddin.CommandBindingTester/Views/DataGridStyleExtension.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,15 @@ public static void UpdateDataGridStyle(this DataGrid dataGrid)
5151
}
5252
else if (column is DataGridCheckBoxColumn dataGridCheckBoxColumn)
5353
{
54-
var style = new Style(typeof(CheckBox));
54+
var style = new Style(typeof(CheckBox), dataGridCheckBoxColumn.ElementStyle);
5555
style.Setters.Add(new Setter(FrameworkElement.HorizontalAlignmentProperty, HorizontalAlignment.Center));
5656
style.Setters.Add(new Setter(FrameworkElement.VerticalAlignmentProperty, VerticalAlignment.Center));
5757
dataGridCheckBoxColumn.ElementStyle = style;
58+
59+
var styleEditing = new Style(typeof(CheckBox), dataGridCheckBoxColumn.EditingElementStyle);
60+
styleEditing.Setters.Add(new Setter(FrameworkElement.HorizontalAlignmentProperty, HorizontalAlignment.Center));
61+
styleEditing.Setters.Add(new Setter(FrameworkElement.VerticalAlignmentProperty, VerticalAlignment.Center));
62+
dataGridCheckBoxColumn.EditingElementStyle = styleEditing;
5863
}
5964
else if (column is DataGridComboBoxColumn dataGridComboBoxColumn)
6065
{

0 commit comments

Comments
 (0)