selecteditem

C#/WPF: Get SelectedItem from TreeView?

Hello, Does anyone know how I can get the SelectedItem (not the Header) from a TreeView? Here is my code: <TreeView Name="treeView1" DataContext="{Binding Path=PresentationsViewModel}" Grid.Column="1" > <TreeViewItem IsExpanded="True" Header="Objects-A-List" DisplayMemberPath="Name" ItemsSource="{Bin...

ASP:ListBox - no selected items on postback?

I have the following markup: <tr> <td valign="top" align="left"> <asp:Label ID="Label1" runat="server" Text="Available Roles" /> <br /> <asp:ListBox ID="availableRolesListBox" runat="server" SelectionMode="Multiple" Width="100px" Rows="10" AutoPostBack="false" /> </td> <td valign="top" align="center">...

wpf: how to make ComboBoxItems hold integers in xaml

ok, I must be having a brain freeze here... I have a ComboBox with 6 items and I'm trying to bind the selected item to an integer value. Its not working, I suspect its because the ComboBoxItem's are strings. I don't feel like making a list in code behind just to fill this little box, so is there a way in xaml to tell the comboboxitems t...

Problem: ListBox always auto selects first item.

ListBox's behavior is that the first item is selected automatically, how can I avoid that?? Note: I want to do this with pure xaml, if you have any code-behind ideas then please don't bother yourself. ...

WPF Listview Access to SelectedItem and subitems

Ok, I am having more problems with my C# WPF ListView control. Here it is in all its glory: <Window x:Class="ebook.SearchResults" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"Title="ISBNListView" Height="503" Width="1004"> <Grid> <ListView Name="listView1" Ma...

WPF TabControl Change selected tab

Hi I have two questions. How do I programatically change the selected tab in a WPF Tab control from one tab to another. How would I get a reference to this "other tab" in which I want to set the selected tab? ...

How to set an (unbound) SelectedIndex for a WPF Windows.Controls.ComboBox?

Hi, This should be easy but it's not working. I have a WPF combobox bound to a List. The items populate just fine I want the first item to show on startup. However! If the SelectedIndex is set to 0 or anything else it stays blank. Wozzup? Code Result: No item selected when the form loads. :-( ...

WPF ComboBox SelectedItem not Updating

I am facing a problem while working with a WPF ComboBox. My situation is that I have a ComboBox that is displaying some values. I am adding ContentControls to ComboBox' Items property. I have bound the Content of these ContentControl to some datasource so that I can change the Content dynamically. The problem is if the Content of item wh...

WPF Listview/Gridview setting selected item when combobox is clicked

I'm having issues using a GridView as a ListView's View, what I want to do is fire an event when a user makes a selection from a combobox within the Gridview and pass the selected item within the event. My first issue is that when the user clicks the combobox within a row, the row isnt selected (meaning the selecteditem stays null unle...

How do you reset an AS3 list component so that nothing is selected (NOT selectedIndex=0)

I have a list component on the stage in an AS3 movie. I populate it with values at runtime and the user can select multiple values. When a button is clicked I want the list to reset to a state where nothing is selected, all I can figure out is to set the selected index to 0 and have the first position on the list either blank or readin...

Exposing DataGrid SelectedItem in parent UserControl in WPF

Hi there, I have a User Control with a Data Grid inside it which i re-use in a couple of different Pages and am using M-V-VM. How can I / is it possible to expose the Data Grid's SelectedItem dependancy property as a dependancy property on the User Control which contains it??? The goal being that in a Page using the control, i could ...

How to ensure that no item is selected in databound ListBox?

OK, this must be a duplicate question, but I cannot find the answer: I have a listbox that is databound to a Collection. By default Items[0] is selected. How can I prevent this in order to ensure that the SelectionChanged event is raised any time I click a ListBoxItem? EDIT: I had already dismissed the SelectedIndex=-1 route, but I trie...

IsSynchronizedWithCurrentItem attribute and current item updates

Hello I have a view model to manage a dialog type of view that allows filtering of a listing (if necessary) and selection of an item. The code works fine whether I set IsSynchronizedWithCurrentItem to true or not. My understanding is that this property is not true by default in a ListView, so I'd like to better understand this property....

Getting previously selected item in select box with jQuery

I have a single item HTML select box on which I'd like to find out the what item was selected just prior to changing selection to the new item. By the time the change event is fired, it's already too late: $("select").change(function () { var str = ""; $("select option:selected").each(function () { // this will get me the cur...

Setting does not get removed?

I have both a ListBox (AlarmBox) and a ListView (listView1). They both save into 2 different Properties.Settings (AlarmList and AlarmList2). Properties.Settings.Default.AlarmList.Remove(AlarmList.SelectedItem); Properties.Settings.Default.AlarmList2.Remove(listView1.SelectedItems); AlarmList.Items.RemoveAt(AlarmList.SelectedIndices[0]);...

Silverlight DataGrid Updating SelectedItem from code

When I update a datagrid SelectedItem from code (via a bound object in a ViewModel), how to I get the visual grid to highlight the newly selected item? Thanks, Mark UPDATE: This is still an issue for me. My SelectedItem property already implements change notification, but the datagrid is not VISUALLY displaying which row has been selec...

WPF: Select TreeViewItem broken past the root level

I'm trying to select a TreeViewItem by ID, but having problems getting it to work past the first (root) level. I've done so much reading round on this and am using the method below. private static bool SetSelected(ItemsControl parent, INestable itemToSelect) { if(parent == null || itemToSelect == null) { return false; }...

ListBox TwoWay bind to SelectedItem

I've seen this question asked numerous times and have gone over my code over and over. But when I assign to my SelectedItem-bound property with an object, it does not update the display's selected item. It appears that the ListBox thinks the object I assign is not a member of its items. public class MainViewModel : ViewModelBase { /...

NETCF DataGrid scroll row into view?

Quick question regarding the Compact Framework DataGrid. How can I scroll a particular row into view? We have an application that displays scans in a datagrid. If the user scans a new item I add it to the grid, but if they scan an existing item, I'd like to scroll that item into view. Is there any way to do this? I tried using the foll...

How to delay the setting of bound SelectedItem in a DataGrid

I have a master-detail display in a single Silverlight view. The master is a DataGrid of partially populated items. When I select an item in the DataGrid, my service returns a fully populated data object, which is rendered in the Detail view. This causes a problem when the user scrolls the data grid with the keyboard cursor keys because...