-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from w-ahmad/issue#36
fixed CheckBox & ToggleSwitch column IsReadOnly state issues
- Loading branch information
Showing
9 changed files
with
193 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,49 @@ | ||
using Microsoft.UI.Xaml; | ||
using Microsoft.UI.Xaml.Controls; | ||
using Microsoft.UI.Xaml.Controls.Primitives; | ||
using System; | ||
|
||
namespace WinUI.TableView; | ||
|
||
public class TableViewCheckBoxColumn : TableViewBoundColumn | ||
{ | ||
public TableViewCheckBoxColumn() | ||
{ | ||
UseSingleElement = true; | ||
} | ||
|
||
public override FrameworkElement GenerateElement() | ||
{ | ||
var checkBox = new CheckBox | ||
{ | ||
MinWidth = 20, | ||
MaxWidth = 20, | ||
IsEnabled = !IsReadOnly, | ||
Margin = new Thickness(12, 0, 12, 0), | ||
HorizontalAlignment = HorizontalAlignment.Center | ||
HorizontalAlignment = HorizontalAlignment.Center, | ||
UseSystemFocusVisuals = false, | ||
}; | ||
|
||
checkBox.SetBinding(ToggleButton.IsCheckedProperty, Binding); | ||
UpdateCheckBoxState(checkBox); | ||
|
||
return checkBox; | ||
} | ||
|
||
public override FrameworkElement GenerateEditingElement() | ||
{ | ||
return GenerateElement(); | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public override void UpdateElementState(TableViewCell cell) | ||
{ | ||
if (cell?.Content is CheckBox checkBox) | ||
{ | ||
UpdateCheckBoxState(checkBox); | ||
} | ||
} | ||
|
||
private void UpdateCheckBoxState(CheckBox checkBox) | ||
{ | ||
checkBox.IsHitTestVisible = TableView?.IsReadOnly is false && !IsReadOnly; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.