Search Results

Search found 365 results on 15 pages for 'selecteditem'.

Page 1/15 | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Silverlight nested RadGridView SelectedItem DataContext

    - by Ciaran
    Hi, I'm developing a Silverlight 4 app and am using the 2010 Q1 release 1 RadGridView. I'm developing this app using the MVVM pattern and trying to keep my codebehind to a minimum. On my View I have a RadGridView and this binds to a property on my ViewModel. I am setting a property via the SelectedItem. I have a nested RadGridView and I want to set a property on my ViewModel to the SelectedItem but I cannot. I think the DataContext of my nested grid is the element in the parent's bound collection, rather than my ViewModel. I can easily use codebehind to set my ViewModel property from the SelectionChanged event on the nested grid, but I'd rather not do this. I have tried to use my viewModelName in the ElementName in my nested grid to specify that for SelectedItem, the ViewModel is the DataContext, but I cannot get this to work. Any ideas? Here is my Xaml: <grid:RadGridView x:Name="master" ItemsSource="{Binding EntityClassList, Mode=TwoWay}" SelectedItem="{Binding SelectedEntityClass, Mode=TwoWay}" AutoGenerateColumns="False" > <grid:RadGridView.Columns> <grid:GridViewSelectColumn></grid:GridViewSelectColumn> <grid:GridViewDataColumn DataMemberBinding="{Binding Description}" Header="Description"/. </grid:RadGridView.Columns> <grid:RadGridView.RowDetailsTemplate> <DataTemplate> <grid:RadGridView x:Name="child" ItemsSource="{Binding EntityDetails, Mode=TwoWay}" SelectedItem="{Binding DataContext.SelectedEntityDetail, ElementName='RequestView', Mode=TwoWay}" AutoGenerateColumns="False" > <grid:RadGridView.Columns> <grid:GridViewSelectColumn></grid:GridViewSelectColumn> <grid:GridViewDataColumn DataMemberBinding="{Binding ServiceItem}" Header="Service Item" /> <grid:GridViewDataColumn DataMemberBinding="{Binding Comment}" Header="Comments" /> </grid:RadGridView.Columns> </grid:RadGridView> </DataTemplate> </grid:RadGridView.RowDetailsTemplate> </grid:RadGridView>

    Read the article

  • Silverlight DataGrid Updating SelectedItem from code

    - by Mark Cooper
    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 selected - i.e. it is not getting highlighted.

    Read the article

  • WPF ListView SelectedItem is null

    - by ozczecho
    Hi All I have a Listview that has a checkbox as one of the columns. If I click anywhere but the actual checkbox the SelectedItem of the ListView is set to the current selected row, as expected. If, on the other hand I click onto the checkbox (without clicking on the row first) then the SelectedItem is null or the previously clicked row. Can anyone help me out.... Cheers <ListView Width="auto" SelectionMode="Single" x:Name="listBox" ItemsSource="{Binding MyData}" SelectedItem="{Binding Path=SelectedMyData}"> <ListView.View> <GridView> <GridViewColumn Header="Date" Width="120"> <GridViewColumn.CellTemplate> <DataTemplate> <ContentPresenter Style="{StaticResource DateTimeContent}" Content="{Binding MyDate}"/> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> <GridViewColumn.CellTemplate> <DataTemplate> <CheckBox IsThreeState="False" Checked="OnChkChecked" Unchecked="OnChkChecked" IsChecked="{Binding IsCorrect}"></CheckBox> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> </GridView> </ListView.View> </ListView>

    Read the article

  • WPF - Setting ComboBox.SelectedItem in XAML based on matching object

    - by Andy T
    Hi, so, I have templated combobox that is basically acting as a simple colour palette. It is populated with a list of SolidColorBrush objects. Fine. Now, I have some data that holds the hex value of the current colour. I have a converter that converts the hex into a SolidColorBrush. Also fine. Now, I want to set the SelectedItem property of the combobox based on the colour from my datasource. Since my combo is populated with objects of type SolidColourBrush, and my binding converter is returning a SolidColorBrush, I assumed it would be as simple as saying: SelectedItem="{Binding Color, Converter={StaticResource StringToBrush}}" However... it doesn't work :( I've tested that the binding is working behind the scenes by using the exact same value for the Background property of the combobox. It works fine. So, clearly I can't just say SelectedItem = [something] where that [something] is basically an object equal to the item I want to be selected. What is the right way to do this? Surely it's possible in a XAML-only styley using binding, and I don't have to do some nasty C# iterating through all items in the combobox trying to find a match (that seems awfully old-school)...? Any help appreciated. Many thanks! AT

    Read the article

  • Wpf SelectedItem wont work for a Combobox in a ListView

    - by ChristianRo
    Hi there, I´ve got a problem with a Combobox in a ListView. I´ve got a class called "Substrate". This class contains an object of a class called "SubstrateType". I want to show the objects of the class "Substrate" in a Listview. Each property of the "Substrate" is presented in the columns of the Listview. For the different "SubstrateType" I want to use a combobox. In the XAML I tried it like this: <ComboBox Name="CBType" ItemsSource="{Binding ElementName=SettingsSubstrate, Path=TypeList}" SelectedItem="{Binding Path=Substrate.SubstrateType}" DisplayMemberPath="Description"/> In the code-behind I got two ObservableCollections. One for all Substrates and one for all possible SubstrateTypes. The combobox displays all SubstrateTypes if you click on it. But the combobox has no selecteditem if you dont select one. http://i44.tinypic.com/2eakxav.png Thanks in advance.

    Read the article

  • WPF ComboBox SelectedItem - change to previous value

    - by Taylor
    Hello, I have a ComboBox that has the SelectedItem bound to the ViewModel. <ComboBox SelectedItem="{Binding SelItem, Mode=TwoWay}" ItemsSource="{Binding MyItems}"> When the user selects a new Item in the View ComboBox, I want to display a prompt and verify that they want to make the change. In the SetItem Property setter in the View Model, I display a Dialog to confirm the selection. When they say yes, it works fine. My problem is, when the user clicks on "No" I am not sure who to get the ComboBox to revert back to the previous value. The Property in the ViewModel has the correct older value, however in the View the ComboBox displays the newly Selected Value. I want the user to select an item, confirm they want to go ahead with it, and if they decide not to, I want the ComboBox to revert back to the previous item. How can I accomplish this? Thanks!

    Read the article

  • SubSonic 3 screws up selecteditem?

    - by SteveCav
    If you have a moment, please try this: -Download Subsonic 3. -Start a new proj and add SS's ActiveRecord templates. -Point it to any SQL Server DB and generate the classes. -Add a WPF project. -Create a window and add a combobox or listbox. -Set the ItemsSource from the SS DAL, and format it how you wish. -Add a button that will show you some value from the SelectedItem (using messagebox, console, whatever). -Run the project. -Click on the third item in the list. -Click on the second item in the list. -Click on the button. When I do that, the button gives me the value of the THIRD item, not the second. In other words, once the SelectedItem is set the first time it STAYS, no matter which item is subsequently highlighted on the screen. This is happening to me whatever control I use (combobox, listbox, even datagrid) and it ONLY happens with Subsonic Activerecord objects. If I write my own POCOs with identical properties and bind a list of them instead, the controls behave as expected. Does this happen to you? Any ideas?

    Read the article

  • WPF ComboBox SelectedItem not Updating

    - by viky
    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 which is selected changes the item in ComboBox drop down updates but item in ComboBox SelectionChange remains same. Any suggestions please?

    Read the article

  • MVVM - ListBox SelectedItem Binding Property Going Null

    - by Peanut
    So i have a listbox: <ListBox x:Name="listbox" HorizontalAlignment="Left" Margin="8,8,0,8" Width="272" BorderBrush="{x:Null}" Background="{x:Null}" Foreground="{x:Null}" ItemsSource="{Binding MenuItems}" ItemTemplate="{DynamicResource MenuItemsTemplate}" SelectionChanged="ListBox_SelectionChanged" SelectedItem="{Binding SelectedItem}"> </ListBox> and i have this included in my viewmodel: public ObservableCollection<MenuItem> MenuItems { get { return menuitems; } set { menuitems = value; NotifyPropertyChanged("MenuItems"); } } public MenuItem SelectedItem { get { return selecteditem; } set { selecteditem = value; NotifyPropertyChanged("SelectedItem"); } } and also in my viewmodel: public void UpdateStyle() { ActiveHighlight = SelectedItem.HighlightColor; ActiveShadow = SelectedItem.ShadowColor; } So, the objective is to call UpdateStyle() whenever selectedchanged event is fired. So in the .CS file, i call UpdateStyle(). The problem is, whenever I get into the selectionchanged event method, my ViewModel.SelectedItem is always null. I tried debugging this to see if the binding was working correctly, and it is. When I click on an item in the listbox, the SelectedItem Set is triggered, setting the value... but somewhere inbetween that and the selected changed (In the CS File) It gets reset to Null. Can anyone help out? Thanks

    Read the article

  • WPF: ComboBox with selecteditem set make not use of SelectedIndex=0 ?

    - by msfanboy
    Hello, Why is the first element in my combobox popup menu not shown in the selected item area of my combobox , when I use the SelectedItem binding? Without that it is showing up ?? Using the same code selecteditem + selectedindex that is no problem! <ComboBox ItemsSource="{Binding SchoolclassSubjectViewModels}" SelectedItem="{Binding SelectedSchoolclassSubjectViewModel}" SelectedIndex="0" Height="23" HorizontalAlignment="Left" Margin="375,13,0,0" VerticalAlignment="Top" Width="151"> <ComboBox.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <TextBlock Text="{Binding SchoolclassName}" /> <TextBlock Text=" " /> <TextBlock Text="{Binding SubjectName}" /> </StackPanel> </DataTemplate> </ComboBox.ItemTemplate> </ComboBox> Well as workaround I used: SchoolclassSubjectViewModels.Add(schoolclassSubjectVM); SelectedSchoolclassSubjectViewModel = schoolclassSubjectVM; and this: SelectedItem="{Binding SelectedSchoolclassSubjectViewModel,Mode=TwoWay}" but I would prefer the xaml only way as it should really work.

    Read the article

  • C# ComboBox SelectedItem [closed]

    - by Diane
    I have a combobox with a list of values. I would like the selected index to be a value from the database. I first create the combobox, fill it with values from a dataset like this: ComboBox cmb_Relay = new ComboBox(); cmb_Relay.DataSource = ds2.Tables[0]; cmb_Relay.DisplayMember = "Relay"; cmb_Relay.ValueMember = "Relay"; Next, I set the SelectedIndex to the value of a specific field value: cmb_Relay.SelectedItem = ds2.Tables[0].Rows[j][2]; I get the follwing error: InvalidArgument=Value of '3' is not valid for 'SelectedIndex'. Parameter name: SelectedIndex

    Read the article

  • Flex Spark DropDownList selectedItem didn't update after dataProvider changed

    - by Candy Chiu
    I have two dataProvider's for one DropDownList. The following code can be compiled and run. <?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" creationComplete="flipLast()" minWidth="955" minHeight="600"> <fx:Script> <![CDATA[ import mx.collections.ArrayCollection; public function flipLast():void { if( last ) { list.dataProvider = dp1; list.selectedItem = "Flex"; } else { list.dataProvider = dp2; list.selectedItem = "Catalyst"; } last = !last; } public var last:Boolean = true; public var dp1:ArrayCollection = new ArrayCollection( [ "Flex", "Air" ] ); public var dp2:ArrayCollection = new ArrayCollection( [ "Catalyst", "FlashBuilder" ] ); ]]> </fx:Script> <s:VGroup> <s:DropDownList id="list" requireSelection="true" /> <s:Label id="listSelectedItem" text="{list.selectedItem}" /> <s:Label id="listSelectedIndex" text="{list.selectedIndex}" /> <s:Button label="Flip" click="flipLast()" /> </s:VGroup> </s:Application> Scenario 1: dataProvider updated, but selectedIndex is the same. At startup: [ listSelectedItem=Flex, listSelectedIndex=1 ]. Click Flip: dataProvider is updated, but still [ listSelectedItem=Flex, listSelectedIndex=1 ]. Scenario 2: dataProvider updated, selectedIndex is also updated. At startup: [ listSelectedItem=Flex, listSelectedIndex=1 ]. Select Air from list: [ listSelectedItem=Air, listSelectedIndex=2 ]. Click Flip: dataProvider is updated, but still [ listSelectedItem=Catalyst, listSelectedIndex=1 ]. Seems to me that selectedItem is driven by selectedIndex. selectedItem updates only when selectedIndex updates. Shouldn't selectedItem be updated when dataProvider is updated? Is binding to selectedItem flawed?

    Read the article

  • [WPF] SelectionChanged of a child ListBox

    - by quimbs
    Hi, I have a ListBox bound to an ObservableCollection with an ItemTemplate that contains another ListBox. First of all, I tried to get the last selected item of all the listboxes (either the parent and the inner ones) from my MainWindowViewModel this way: public object SelectedItem { get { return this.selectedItem; } set { this.selectedItem = value; base.NotifyPropertyChanged("SelectedItem"); } } So, for example, in the DataTemplate of the items of the parent ListBox I've got this: <ListBox ItemsSource="{Binding Tails}" SelectedItem="{Binding Path=DataContext.SelectedItem, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}"/> The problem now, is that when I select an item from the parent ListBox and then an item from a child listbox, I get this: http://i40.tinypic.com/j7bvig.jpg As you can see, two items are selected at the same time. How can I solve that? Thanks in advance.

    Read the article

  • TwoWay Binding to ListBox SelectedItem on more than one list box in WPF

    - by Dan Bryant
    I have a scenario where I have a globally available Properties window (similar to the Properties window in Visual Studio), which is bound to a SelectedObject property of my model. I have a number of different ways to browse and select objects, so my first attempt was to bind them to SelectedObject directly. For example: <ListBox ItemsSource="{Binding ActiveProject.Controllers}" SelectedItem="{Binding SelectedObject, Mode=TwoWay}"/> <ListBox ItemsSource="{Binding ActiveProject.Machines}" SelectedItem="{Binding SelectedObject, Mode=TwoWay}"/> This works well when I have more than one item in each list, but it fails if a list has only one item. When I select the item, SelectedObject is not updated, since the list still thinks its original item was selected. I believe this happens because the two way binding simply ignores the update from source when SelectedObject is not an object in the list, leaving the list's SelectedItem unchanged. In this way, the bindings become out of sync. Does anybody know of a way to make sure the list boxes reset their SelectedItem when the SelectedObject is not in the list? Is there a better way to do this that doesn't suffer from this problem?

    Read the article

  • Casting SelectedItem of WPF Combobox to Color causes exception

    - by Nick Udell
    I have a combobox databound to the available system colors. When the user selects a color the following code is fired: private void cboFontColour_SelectionChanged(object sender, SelectionChangedEventArgs e) { Color colour = (Color)(cboFontColour.SelectedItem); } This throws a Casting Exception with the following message: "Specified cast is not valid." When I hover over cboFontColour.SelectedItem in the debugger, it is always a Color object. I do not understand why the system seemingly cannot cast from Color to Color, any help would be much obliged.

    Read the article

  • Binding Combobox SelectedItem by a field's value

    - by Navid Farhadi
    Combobox bind to a set of Provinces, Village object has ProvinceID field and i want to bind SelectedItem of Combobox to a Province with Village's ProvinceID. My code is: <ComboBox ItemsSource="{Binding ProvincesList}" DisplayMemberPath="ProvinceName" SelectedValuePath="ProvinceID" SelectedValue="{Binding Village.ProvinceID}" /> But SelectedItem is anything.

    Read the article

  • SelectedItem of listbox - BindableCollection is binded on listbox

    - by user572844
    Hi, I bind BindableCollection from caliburn micro on listbox. Also I bind selected listbox item on property in view model. After I select some item on listbox, property SelectedFriedn which is bind on SelectedItem of listbox is still null. Code from view model: private BindableCollection<UserInfo> _friends; //bind on listbox public BindableCollection<UserInfo> Friends { get { return _friends; } set { _friends = value; NotifyOfPropertyChange(() => Friends); } } private UserInfo _selectedFriend = new UserInfo(); //bind on SelectedItem property of listbox public UserInfo SelectedFriend { get { return _selectedFriend; } set { _selectedFriend = value; NotifyOfPropertyChange(() => SelectedFriend); } } In view I have this: <ListBox Name="Friends" SelectedIndex="{Binding Path=SelectedFriendsIndex,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" SelectedItem="{Binding Path=SelectedFriend, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" Style="{DynamicResource friendsListStyle}" IsTextSearchEnabled="True" TextSearch.TextPath="Nick" Grid.Row="2" Margin="4,4,4,4" PreviewMouseRightButtonUp="ListBox_PreviewMouseRightButtonUp" PreviewMouseRightButtonDown="ListBox_PreviewMouseRightButtonDown" MouseRightButtonDown="ListBox_MouseRightButtonDown" Micro:Message.Attach="[MouseDoubleClick]=[Action OpenChatScreen()]" > Where can be problem?

    Read the article

  • WPF: Problem with SelectedItem for ComboBox

    - by Anry
    XAML: <ComboBox Height="27" Margin="124,0,30,116" Name="cbProductDefaultVatRate" VerticalAlignment="Bottom" ItemsSource="{Binding}"> <ComboBox.ItemTemplate> <DataTemplate> <Label Height="26" Content="{Binding Path=Value}"/> </DataTemplate> </ComboBox.ItemTemplate> </ComboBox> Set Data for cbProductDefaultVatRate.Items (Type - VatRate): private void ShowAllVatRates() { cbProductDefaultVatRate.Items.Clear(); cbProductDefaultVatRate.ItemsSource = new VatRateRepository().GetAll(); } Similarly, I defined property: private Product SelectedProduct { get; set; } The Product contains VatRate: SelectedProduct.DefaultVatRate How to set SelectedItem equal SelectedProduct.DefaultVatRate? I tried: cbProductDefaultVatRate.SelectedItem = SelectedProduct.DefaultVatRate; But it does not work. Thank you for answers!

    Read the article

  • WPF MVVM ComboBox SelectedItem or SelectedValue not working

    - by cjibo
    Update After a bit of investigating. What seems to be the issue is that the SelectedValue/SelectedItem is occurring before the Item source is finished loading. If I sit in a break point and weight a few seconds it works as expected. Don't know how I'm going to get around this one. End Update I have an application using in WPF using MVVM with a ComboBox. Below is the ViewModel Example. The issue I'm having is when we leave our page and migrate back the ComboBox is not selecting the current Value that is selected. View Model public class MyViewModel { private MyObject _selectedObject; private Collection<Object2> _objects; private IModel _model; public MyViewModel(IModel model) { _model = model; _objects = _model.GetObjects(); } public Collection<MyObject> Objects { get { return _objects; } private set { _objects = value; } } public MyObject SelectedObject { get { return _selectedObject; } set { _selectedObject = value; } } } For the sake of this example lets say MyObject has two properties (Text and Id). My XAML for the ComboBox looks like this. XAML <ComboBox Name="MyComboBox" Height="23" Width="auto" SelectedItem="{Binding Path=SelectedObject,Mode=TwoWay}" ItemsSource="{Binding Objects}" DisplayMemberPath="Text" SelectedValuePath="Id"> No matter which way I configure this when I come back to the page and the object is reassembled the ComboBox will not select the value. The object is returning the correct object via the get in the property though. I'm not sure if this is just an issue with the way the ComboBox and MVVM pattern works. The text box binding we are doing works correctly.

    Read the article

  • Xceed DataGrid SelectedItem issue

    - by Patrick K
    In my project I have an Xceed data grid which is bound to a data source with many records and record details. I am attempting to create a context menu option that will allow the user to search for a specific detail in a specific column. While I have successfully completed the functionality there is a UI part that is giving me some trouble, in that when I select the row in C#, if that row is not in view the row is never focused on. Thus the user has to scroll up and down looking for the row with expanded details. I am able to set the SelectedRow and expand the details like so: this.grid.AutoFilterValues[userColumn].Clear(); this.grid.AutoFilterValues[userColumn].Add(userValue); if (this.creditLinesDataGridControl.Items.Count > 0) { this.grid.SelectedItem = this.grid.Items[0]; this.grid.ExpandDetails(this.grid.Items[0]); } else { MessageBox.Show("Value not found in column: " + userColumn); } this.grid.AutoFilterValues[userColumn].Clear(); where userColumn and userValue are set previously in the method. How can I make the grid focus on the row after I've set the SelectedItem and expanded the details? Thanks, Patrick

    Read the article

  • Binding a ListBox's SelectedItem in the presence of BindingNavigator

    - by Reinderien
    Hello. I'm trying to bind a ListBox's SelectedItem data to a property. The following code is an example: using System; using System.Collections.Generic; using System.Windows.Forms; namespace BindingFailure { static class Program { class OuterObject { public string selected { get; set; } public List<string> strings { get; set; } } public static void Main() { List<OuterObject> objs = new List<OuterObject>() { new OuterObject(), new OuterObject() }; objs[0].strings = new List<string> { "one", "two", "three" }; objs[1].strings = new List<string> { "four", "five", "six" }; Form form = new Form(); BindingSource obs = new BindingSource(objs, null), ibs = new BindingSource(obs, "strings"); BindingNavigator nav = new BindingNavigator(obs); ListBox lbox = new ListBox(); lbox.DataSource = ibs; lbox.DataBindings.Add(new Binding("SelectedItem", obs, "selected")); form.Controls.Add(nav); form.Controls.Add(lbox); lbox.Location = new System.Drawing.Point(30, 30); Application.Run(form); } } } If you just select an item, move forward, select an item and then exit, it works as expected. But if you switch back and forth between the two outer objects with the navigator, the selected item seems to be overwritten with an incorrect value. Ideas on how to fix this? Thanks in advance.

    Read the article

1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >