MaterialDesignInXAML / MaterialDesignInXAML/MaterialDesignInXamlToolkit

MaterialDesignToolToggleListBox with RadioButton behaviour

Abierto
#1,254 1 comentario 8 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

enhancement
Lenguaje dominante
C#
Estrellas
16.3k
Forks
3.5k
Merge medio
1 d 22 h
PR fusionados (30 d)
8

Descripción

Background

I'm using the MaterialDesignToolToggleListBox for selecting one of up to three possible modes that can be available to the user. The current implementation of MaterialDesignToolToggleListBox will allow the user to unselect items in the list box which leaves us with no item selected.

Current Behaviour

CurrentBehaviour

Since i'm binding the SelectedValue of the ListBox I will get a binding/validation error since the SelectedItem will be null when the user unselect the item.

Expected Behaviour

ExpectedBehaviour

Solutions

I would like to set a property on ListBoxAssist or use a new style to get a RadioButton behaviour on MaterialDesignToolToggleListBox.

  1. Create a new style MaterialDesignToolRadioButtonListBox which uses RadioButton to achieve the desired result. (I have not tried this)
  2. Use an attached property to hook into the SelectionChanged event and prevent unselect. Possible name could be PreventUnselect

Pseudo code for option 2

private void SelectionChanged(object sender, SelectionChangedEventArgs e)
{
    if(sender is ListBox listBox)
    {
        if (ListBoxAssist.GetIsToggle(listBox) &&
            listBox.SelectionMode == SelectionMode.Single)
        {
            if (e.AddedItems.Count == 0 && e.RemovedItems.Count == 1)
            {
                listBox.SelectedItem = e.RemovedItems[0];
            }
        }
    }            
}

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Empieza localizando MaterialDesignToolToggleListBox y ListBoxAssist; después, inspecciona cómo la selección de alternancia gestiona SelectionChanged para controles ListBox de selección única. Compara los enfoques propuestos basados en style y attached property; el trabajo estará terminado cuando no se pueda borrar el elemento seleccionado y el binding de SelectedValue siga siendo válido.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
csharp
Área
desktop
Tipo de issue
Nueva funcionalidad
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.