selecteditem

WPF ComboBox Doesn't Display SelectedItem after one DataTrigger but does for another

你离开我真会死。 提交于 2019-12-05 11:17:14
So I have a combobox I'd like to reuse for multiple sets of data rather than having 3 separate comboboxes. Maybe this is bad and someone can tell me so. I'm open to all ideas and suggestions. I'm just trying to clean up some code and thought one combobox rather than 3 was cleaner. Anyway the ItemsSource and SelectedItem all should change when another ComboBox's value is changed which Raises the Property Changed value for the ComboBox that isn't working. The worst part is when CurSetpoint.ActLowerModeIsTimerCondition is true it always loads the SelectedItem correctly but when going from that to

Getting ValueMember from selected item in a ListBox with C#

寵の児 提交于 2019-12-05 08:20:57
I'm trying to get all the selected items ValueMember from a ListBox with C#. For ex.: I've a list like this: ID | Name and Lastname ---------------------- 1 | John Something 2 | Peter Something2 3 | Mary Smith This structure is part of my ListBox. I've builded this listbox with this code: private void fill_people_listBox() { this.listBoxPeople.DataSource = db.query("SELECT ...."); this.listBoxPeople.DisplayMember = "people_name_last"; this.listBoxPeople.ValueMember = "people_id"; } The ListBox is successfully populated. When the user wants to save the changes I've to loop throught this list to

Winforms ComboBox SelectedItem changing does not affect the BindingSource

不羁的心 提交于 2019-12-05 04:20:36
I am making C# / WinForms application. The problem I couldn't solve (yet) is that when I change the SelectedItem of ComboBox programatically, it is changed until the ComboBox loses the focus, after that it "reminds" its value before assigning the SelectedItem. I think that it takes the old value from binding source. When choosing an item using UI the underlying bound object is updated normally but it doesn't so when I'm assigning new value to SelectedItem programatically. Just for additional info: I am trying to implement "undo", which means I am saving every change somewhere and when Edit>>

WPF How to change the listbox selected item text color when the list box loses focus

∥☆過路亽.° 提交于 2019-12-05 00:09:33
问题 I've been searching for how to change the text color of a selected item in a list box that has lost focus. <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent"/> <SolidColorBrush x:Key="{x:Static SystemColors.ControlBrushKey}" Color="Transparent"/> <SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="Orange"/> These three tags take care of most of the work, but my list box has a black background and when the control loses focus, the

WPF Tab Control: How do I get the currently selected tab?

懵懂的女人 提交于 2019-12-04 23:59:29
In my tab SelectionChanged event (is this the correct event, I can't find a tab changed event?), how do I access the new tab? Also from outside this event in normal code, how do I access the currently selected tab? TabControl.SelectionChanged += new System.Windows.Controls.SelectionChangedEventHandler(TabControl_SelectionChanged); void TabControl_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { //How so access my currently selected tab??? } MarcelDevG TabControl.SelectedItem is the selected tab. cast it to a TabItem to get the properties. What I mostly do

Type list of selected items in a wpf datagrid

六月ゝ 毕业季﹏ 提交于 2019-12-04 20:42:30
问题 I send the selected items to a specific command when the selection changes (each item is a class X) I get them as object how can I convert it to a list? I tried: 1. IList<x> SelectedItemsList = obj as ObservableCollection<x>; 2. IList<x> SelectedItemsList = obj as IList<x>; 3. List<x> SelectedItemsList = obj as List<x>; It did not help. This type of list: System.Windows.Controls.SelectedItemCollection I want to convert it to my list: ObservableCollection<x>/IList<x>/List<x> (the ViewModel not

How to keep an item selected? - ListView

穿精又带淫゛_ 提交于 2019-12-04 20:10:50
I would like to keep an item selected, on a ListView, when the user clicks on a space which has no item. For example, the space below the items, but still on the ListView component. I've change the ListView property "HideSelection" to false, but that only works when the focus is changed to another component; not when the user clicks on the ListView itself. Thanks! This is something you normally shouldn't fix. The user clicked somewhere intentionally, that might well be because she wanted to deselect an item. If it was unintentional then she'll understand what happened and know how to correct

How to check whether the item in the combo box is selected or not in C#?

与世无争的帅哥 提交于 2019-12-04 19:32:46
问题 I have a combo box in which I have to display the dates from a database. The user has to select a date from the combo box to proceed further, but I don't know how to make the user aware of selecting the item from the combo box first in order to proceed further. What process should be followed so that a user can get a message if he has not selected the date from the combo? 回答1: if (string.IsNullOrEmpty(ComboBox.SelectedText)) { MessageBox.Show("Select a date"); } 回答2: Here is the perfect

Displaying Content only when ListViewItem is Selected

只谈情不闲聊 提交于 2019-12-04 16:44:28
I have a ListBox when one of the ListBoxItems are selected I want to change the visibility of the button "View" and display it. Meaning that the default state is Hidden. Is this possible and if so, do I solve this with a trigger in XAML or in code behind? XAML Piece <ListBox Background="Transparent" ItemContainerStyle="{StaticResource listBoxTemplate}" BorderThickness="0"> <ListBox.ItemsPanel> <ItemsPanelTemplate> <StackPanel Orientation="Vertical" VerticalAlignment="Center" /> </ItemsPanelTemplate> </ListBox.ItemsPanel> <ListBox.ItemTemplate> <DataTemplate> <Grid Background="Beige" Margin="10

Problem with SelectedItem of WPF Editable ComboBox with DataTemplate

匆匆过客 提交于 2019-12-04 12:45:38
I’m having the following issue with WPF ComboBox : XAML: <Window.Resources> <ResourceDictionary> <DataTemplate DataType="{x:Type this:Data}"> <ComboBox IsTextSearchEnabled="False" IsEditable="True" Text="{Binding Value}" ItemsSource="{Binding Menu}"/> </DataTemplate> </ResourceDictionary> </Window.Resources> <StackPanel> <ContentControl Content="{Binding}"/> <Button Click="ChangeData_Click">Change Data</Button> </StackPanel> Code behind: public Window1() { InitializeComponent(); DataContext = new Data(); } void ChangeData_Click(object sender, RoutedEventArgs e) { DataContext = new Data(); } I