I have a combobox that i would like the physically displayed text to always remain the same.
I want the user to select an item which would then get passed in but then for the actual text on the combobox to remain the same.
on the
FileBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
event i find out which item has been selected with
if (((ComboBox)sender).SelectedItem != null)
{
if (((ComboBox)sender).SelectedItem.ToString() == "New File")
{
}
}
(i will process this more later)
I then try and update the text back to being 'File'.
I have tried numerous approaches which dont seem to work.
I've tried simply doing
FileBox.text = "File";
this.Dispatcher.Invoke(() =>
{
FileBox.Text = "File";
});
FileBox.SelectedItem = "File";
When debugging it does actually seem like the .Text property gets updated, but it then seems to get overridden when the event finishes. For testing i have a button that does:
var text = FileBox.Text;
FileBox.Text = "File";
When i have selected "New File" the var text == New File
And the FileBox.Text code here works and updates it back to File
Do i need to set the text again outside of the SelectionChanged event, and if so how would i go about doing this?
Thanks
EDIT
I do not think this is a duplicate of the one posted as he wants his default to dissapear when something is selected, i want it to reappear