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

[need feedback] Create ToggleGroup control #1254

Closed
wants to merge 1 commit into from

Conversation

jstevans
Copy link
Contributor

@jstevans jstevans commented Nov 1, 2017

This is an early PR for help on next steps -- I saw discussion on #224 that asked for a way to scope groupnames, and it seems like this is what a Control is for.

I'm not extremely familiar with Avalonia/WPF, so could use some feedback on whether this is a good start, and what I need to do to actually have a usable Control (and how to use it).

Ideally, I believe a ToggleGroup should:

  • be able to contain arbitrary other Controls
  • only allow at-most one ToggleButton within it to be selected at a time, by unselecting all other ToggleButtons whenever one is selected

Copy link
Member

@grokys grokys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First of all: sorry for the delay - I've been a bit snowed under recently.

A few small nits regarding getting property names: nameof was added after work was started on Avalonia so we don't yet use it everywhere but it's the preferred way of getting a property name as a string.

Regarding the ToggleGroup control itself: this isn't really what I was imagining. This will only track direct visual children of the ToggleGroup control, which may be enough but my feeling is that a toggle group should instead start a "scope" for all descendant controls.

I think a better way to start off would be to add a GroupName property like in WPF.

Once that is added, then there should be a way to "scope" these group names. I'd imagine this could probably be done as an attached property; we could use a control as you've done here but to me an attached property such as ToggleButton.IsGroupScope="true" would be more similar to other "scope" mechanisms in Avalonia/WPF such as name scopes and focus scopes.

Does that make sense?

public static readonly DirectProperty<ToggleButton, bool> IsCheckedProperty =
AvaloniaProperty.RegisterDirect<ToggleButton, bool>(
"IsChecked",
IsCheckedPropertyName,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer just using nameof(IsChecked) here.


public static readonly DirectProperty<ToggleGroup, ToggleButton> SelectedItemProperty =
AvaloniaProperty.RegisterDirect<ToggleGroup, ToggleButton>(
SelectedItemPropertyName,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, use nameof(SelectedItem) here.

@grokys
Copy link
Member

grokys commented May 15, 2018

This does't seem to have had any further activity so closing for now. Thanks anyway @jstevans!

@grokys grokys closed this May 15, 2018
@robloo
Copy link
Contributor

robloo commented Mar 21, 2021

Probably related to the discussion here microsoft/microsoft-ui-xaml#2310.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants