Establezca el texto de ComboBox haciendo clic en ComboBoxItem
Frecuentes
Visto 80 equipos
0
I have a CustomComboBoxItem which is derived from ComboBoxItem
public class CustomComboBoxItem : ComboBoxItem {
...
protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e)
{
base.OnMouseLeftButtonUp(e);
}
}
I need to set the text of the ComboBox by cliking on the CustomComboBoxItem. I don't want to use the SelectionChanged event on the ComboBox itself because I want it to be set by mouse click.
I really don't have any idea what I should do about it. Please share your ideas with me. thanks a million.
Editar
I have a CustomComboBox which has a TextBox in the ControlTemplate. and in the GetContainerForItemOverride overriden method:
protected override DependencyObject GetContainerForItemOverride()
{
return new CustomComboBoxItem();
}
1 Respuestas
0
Finally I solved the problem with this line of code in CustomComboBoxItem
var parent = ItemsControl.ItemsControlFromItemContainer(this) as CustomComboBox;
contestado el 28 de mayo de 14 a las 18:05
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas c# wpf text combobox or haz tu propia pregunta.
sorry it is all in code-behind. - user3530012
can you try to find Parent? I'll do a test later to see if it possible... - sexta13
Oh that sounds a goon idea. I've found an article about it. stackoverflow.com/questions/2399967/… I'm going to test it. - user3530012
Why don't you just use the default
ComboBox
functionality??? There's aTextBox
en el defectoControlTemplate
and it is automatically set to the selected item too. - Sheridan¿Resolviste tu problema? - sexta13