MaterialDesignInXAML / MaterialDesignInXAML/MaterialDesignInXamlToolkit
MaterialDesignToolToggleListBox with RadioButton behaviour
Nadie ha tomado este issue todavía.
- 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

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

Solutions
I would like to set a property on ListBoxAssist or use a new style to get a RadioButton behaviour on MaterialDesignToolToggleListBox.
- Create a new style
MaterialDesignToolRadioButtonListBoxwhich usesRadioButtonto achieve the desired result. (I have not tried this) - Use an attached property to hook into the
SelectionChangedevent and prevent unselect. Possible name could bePreventUnselect
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
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- 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