Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to usefully subclass DataGridColumn or any of its subclasses #2956

Closed
escape-llc opened this issue Jun 27, 2019 · 3 comments
Closed

Comments

@escape-llc
Copy link

I'm submitting a...

Bug report (I searched for similar issues and did not find one)

Current behavior

The liberal use of internal in DataGridColumn make it impossible to make a 3rd party subclass of anything connected to that class. This leads to compile-time errors like "CS0103 OwningGrid does not exist in the current context" from the subclass.

These properties should be made protected to allow access to subclass creators.

Also, there is a propensity of calling private methods from protected methods that can be overriden, and this causes another maintenance problem, because what should be a one or two method override subclass becomes a nightmare copy/paste job in order to "get at" all the private state and "helpers" that should be protected so subclasses may reuse them too.

Expected behavior

It should be straightforward to make subclasses of DataGridColumn that leverage their implementation to reduce duplicate code or complete rewrites due to inaccessibility.

Minimal reproduction of the problem with instructions

  1. Make a solution for UWP.
  2. Install the packages for Toolkit.
  3. Make a subclass of DataGridComboBox (see below for sample code).
  4. Override the GenerateEditingElement() method.
  5. Attempt to use any of the "helper" methods that would be necessary for a subclass to use, because they access private state in the superclass. For example EnsureColumnBinding(). Or attempt to access the OwnerGrid property, which seems necessary for any subclass of DataGridColumn to access, not just the privileged ones in the same assembly.
  6. Fail due to compiler errors.

Here is a minimal example subclass that fails.

	public class EntityComboBoxColumn : DataGridComboBoxColumn {
		protected override FrameworkElement GenerateEditingElement(DataGridCell cell, object dataItem) {
			EnsureColumnBinding(dataItem);
			EnsureDisplayMemberPathExists();
			EnsureItemsSourceBinding();
			var comboBox = new ComboBox {
				Margin = default(Thickness),
				HorizontalAlignment = HorizontalAlignment.Stretch,
				VerticalAlignment = VerticalAlignment.Center
			};

			return comboBox;
		}
	}

Environment

Since this is a design issue, it appears in all versions of everything. It's nice to have open source everything, but it's also nice to have open subclassing too!

Nuget Package(s): All

Package Version(s): All

Windows 10 Build Number:
- [ x] Fall Creators Update (16299)
- [ ] April 2018 Update (17134)
- [ ] October 2018 Update (17763)
- [ ] Insider Build (build number: )

App min and target version:
- [x ] Fall Creators Update (16299)
- [ ] April 2018 Update (17134)
- [ ] October 2018 Update (17763)
- [ ] Insider Build (xxxxx)

Device form factor:
- [x ] Desktop
- [ ] Mobile
- [ ] Xbox
- [ ] Surface Hub
- [ ] IoT

Visual Studio 
- [ x] 2017 (version: )
- [ ] 2017 Preview (version: )

@ghost ghost added the needs triage 🔍 label Jun 27, 2019
@michael-hawker michael-hawker added the DataGrid 🔠 Issues on DataGrid control label Jul 30, 2019
@Kyaa-dost Kyaa-dost added the bug 🐛 An unexpected issue that highlights incorrect behavior label Sep 5, 2019
@RBrid RBrid added feature 💡 and removed bug 🐛 An unexpected issue that highlights incorrect behavior labels Oct 10, 2019
@ghost
Copy link

ghost commented Oct 18, 2019

This issue has been marked as "Needs: Attention 👋" due to no activity for 7 days. Please triage and assign the issue so the fix can be established.

@ghost ghost added the needs attention 👋 label Oct 18, 2019
@ghost
Copy link

ghost commented Oct 25, 2019

This issue has been marked as "Needs: Attention 👋" due to no activity for 7 days. Please triage the issue so the fix can be established.

@anawishnoff
Copy link

We are not adding features to this DataGrid at this time. If you would like to see this feature in the newly proposed WinUI DataGrid, please add a comment in the WinUI discussion issue. Thanks!

@CommunityToolkit CommunityToolkit deleted a comment Nov 21, 2019
@CommunityToolkit CommunityToolkit deleted a comment Nov 21, 2019
@CommunityToolkit CommunityToolkit deleted a comment Nov 21, 2019
@ghost ghost locked as resolved and limited conversation to collaborators Jan 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants