selecteditem

Confused about CollectionViewSource (SelectedItem not working in combos)

落花浮王杯 提交于 2019-12-01 20:27:20
I have a bunch of combos that all share the same available choices. These choices are provided in a collection exposed from my ViewModel. All fine and dandy. I now want these choices sorted, so I decided to expose an ICollectionView from my ViewModel instead of my usual ReadonlyObservableCollection<T> , and sort the collection view in my ViewModel. class EditStuffViewModel : ViewModelBase { public EditStuffViewModel (ObservableCollection<Choice> choices) { Choices = new CollectionViewSource() { Source = choices }.View; Choices.SortDescriptions.Add(new SortDescription("Name", ListSortDirection

Combobox binding itemsource to custom list and selecteditem to an instance of that list doesn't work

两盒软妹~` 提交于 2019-12-01 06:13:14
I tried really different ways to make my combobox working but I'm still stuck :( Here is a very simplified version of my app : (just edited, sorry for mistakes) <ListView ItemsSource="{Binding People}" SelectedItem="{Binding SelectedPerson}"/> <ComboBox ItemsSource="{Binding Grades}" SelectedItem="{Binding SelectedPerson.MyGrade}" DisplayMemberPath="Name"/> And the code behind : public class Person { private string name; public string Name { get { return name; } set { if (name != value) { name = value; NotifyPropertyChanged("Name"); } } } private Grade myGrade; public Grade MyGrade { get {

Combobox binding itemsource to custom list and selecteditem to an instance of that list doesn't work

女生的网名这么多〃 提交于 2019-12-01 05:33:57
问题 I tried really different ways to make my combobox working but I'm still stuck :( Here is a very simplified version of my app : (just edited, sorry for mistakes) <ListView ItemsSource="{Binding People}" SelectedItem="{Binding SelectedPerson}"/> <ComboBox ItemsSource="{Binding Grades}" SelectedItem="{Binding SelectedPerson.MyGrade}" DisplayMemberPath="Name"/> And the code behind : public class Person { private string name; public string Name { get { return name; } set { if (name != value) {

Need SIMPLE working example of setting WPF MVVM ComboBox ItemsSource based on SelectedValue of second ComboBox

流过昼夜 提交于 2019-12-01 05:32:38
Can anyone show me a simple working example for a WPF MVVM application to set the ItemsSource of combobox B based on the SelectedItem of ComboBox A? It seems from what I've found on this site that it gets all too complicated all too quickly. What's the "right" MVVM way to get it done? Thank you. EDIT I updated using Didier's example. An extract of my XAML: <ComboBox Name="BrowserStackDesktopOS" ItemsSource="Binding Platforms.AvailableBrowserStackDesktopOSes}" SelectedIndex="0" SelectedItem="{Binding Platforms.BrowserStackDesktopOSSelectedValue, Mode=TwoWay}"/> <ComboBox Name=

Need SIMPLE working example of setting WPF MVVM ComboBox ItemsSource based on SelectedValue of second ComboBox

十年热恋 提交于 2019-12-01 04:39:56
问题 Can anyone show me a simple working example for a WPF MVVM application to set the ItemsSource of combobox B based on the SelectedItem of ComboBox A? It seems from what I've found on this site that it gets all too complicated all too quickly. What's the "right" MVVM way to get it done? Thank you. EDIT I updated using Didier's example. An extract of my XAML: <ComboBox Name="BrowserStackDesktopOS" ItemsSource="Binding Platforms.AvailableBrowserStackDesktopOSes}" SelectedIndex="0" SelectedItem="

WPF ListBox - Getting UIElement instead of of SelectedItem

邮差的信 提交于 2019-12-01 02:44:31
I created a ListBox that has a DataTemplate as Itemtemplate . However, is there an easy way to access the generated UIElement instead of the SelectedItem in codebehind? When I access SelectedItem , I just get the selected object from my ItemsSource collection. Is there a way to access the UIElement (ie. the element generated from the DataTemplate together with the bound object)? Szymon Rozga You are looking for the ItemContainerGenerator property. Each ItemsSource has an ItemContainerGenerator instance. This class has the following method that might interest you: ContainerFromItem(object

How do I highlight a treeview selected item with some color?

喜你入骨 提交于 2019-12-01 02:10:47
问题 I have a treeview in WPF. I want a different color when i select the treeviewitem. 回答1: Simple Trigger in TreeView.ItemContainerStyle can't help for default TreeView template. For standard template highlighting is done via background changing for specific element inside TreeView template. This specific element is not accessible for programmer without TreeView template changing. By default resource is used to set background on this element for highlighting. So there are few ways: simple (but

Cannot access the selected items collection when the ListView is in virtual mode?

元气小坏坏 提交于 2019-11-30 23:52:52
I have a ListView in Virtual Mode. I wanna to access SelectedItems property. But when I use ListView1.SelectedItems , I receive the following Exception : Cannot access the selected items collection when the ListView is in virtual mode How can I access to ListView1.SelectedItems in VirtualMode. It is quite old post but maybe someone else will benefit. Simply use ListView.SelectedIndexCollection col = listView.SelectedIndices; Then you can access an item: forearch(var item in col) { string txt = listView.Items[item].Text; } ..but you won't be able to iterate through ListView.Items using foreach

Combobox SelectedItem doesn't update when source changes

为君一笑 提交于 2019-11-30 19:28:50
I have a viewmodel which implement INotifyPropertyChanged . On this viewModel is a property called SubGroupingView . This property is bound to the selected item of a combo box. When i change the combo box, the source property is being updated fine, but when I change the source property or when the control is initialized, the combobox.selectedItem is NOT reflecting what exists in the property. Here is some code to get you started: <ComboBox Grid.Column="3" Grid.Row="1" Margin="0,1,4,1" SelectedItem="{Binding Path=SubGroupingView, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay, diag

How to get selected option using Selenium WebDriver with Python?

你离开我真会死。 提交于 2019-11-30 17:55:53
How to get selected option using Selenium WebDriver with Python: Someone have a solution for a getFirstSelectedOption ? I'm using this to get the select element: try: FCSelect = driver.find_element_by_id('FCenter') self.TestEventLog = self.TestEventLog + "<br>Verify Form Elements: F Center Select found" except NoSuchElementException: self.TestEventLog = self.TestEventLog + "<br>Error: Select FCenter element not found" Is there an equivalent or something close to 'getFirstSelectedOption' like this: try: FCenterSelectedOption = FCenterSelect.getFirstSelectedOption() self.TestEventLog = self