I have a textbox that takes user input, the input is added to a listbox, how do I set it so that the user can't add an empty string to the listbox?
<TextBox x:Name="txtNewCategory" Grid.Row="1" Width="400" Height="25" Margin="10" Text="{Binding UserInput, Mode=TwoWay}"><TextBox.Effect><DropShadowEffect BlurRadius="5" ShadowDepth="3" /></TextBox.Effect></TextBox>
private void btnAdd_Click(object sender, RoutedEventArgs e) { try { ViewModelAddCategoriesWindow dataContext = (ViewModelAddCategoriesWindow)this.DataContext; this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }