Cannot get current text in an Editable ComboBox
Posted: 05 Feb 2015, 06:43
Hey all,
I'm creating an editable combobox with a few pre-set options, designed to let a user type in a destination for a file or select from some convenient presets, but I've run into a few problems. I'm creating the combobox like this:
It seems to be that comboBox.GetText() should return the current state of the text in the box that's being edited, but unfortunately it doesn't seem to. Instead, i'm getting what was originally in that spot before any editing took place (I.E: It's impossible for me to find out what the current string of edited text in the combobox is).
In Addition to this, when I call comboBox.GetSelectedItem().GetTag() It gives me a BaseComponent object back, which doesn't contain any information - notably it doesn't contain the string tag that I originally put there, meaning that too is impossible to get out. I can work around this issue by pushing to information into the name field (which is correctly preserved), but being unable to get the current text in the editable text box of the combobox seems to make ComboBox.IsEditable useless.
I'm creating an editable combobox with a few pre-set options, designed to let a user type in a destination for a file or select from some convenient presets, but I've run into a few problems. I'm creating the combobox like this:
Code: Select all
<ComboBox VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Margin="6, 0" Height="24"
IsEditable="True" IsSynchronizedWithCurrentItem="True" Name="fileLocationBox" SelectedIndex="0">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" />
</DataTemplate>
</ComboBox.ItemTemplate>
<ComboBoxItem Tag="MyDocuments">MyDocuments/PEVS</ComboBoxItem>
<ComboBoxItem Tag="Desktop">Desktop</ComboBoxItem>
<ComboBoxItem Tag="MyPictures">MyPictures/PEVS</ComboBoxItem>
<ComboBoxItem >Current Folder</ComboBoxItem>
</ComboBox>In Addition to this, when I call comboBox.GetSelectedItem().GetTag() It gives me a BaseComponent object back, which doesn't contain any information - notably it doesn't contain the string tag that I originally put there, meaning that too is impossible to get out. I can work around this issue by pushing to information into the name field (which is correctly preserved), but being unable to get the current text in the editable text box of the combobox seems to make ComboBox.IsEditable useless.