<ComboBox x:Name="cboDistrict" IsSynchronizedWithCurrentItem="True" Grid.Column="1" Grid.Row="0" Style="{DynamicResource BaseComboBox}" TabIndex="20" ItemsSource="{Binding Path=AllDistricts, Mode=Default}" SelectedItem="{Binding Path=BodyTextDistrict, Mode=TwoWay}"> <ComboBox.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding }"/> </DataTemplate> </ComboBox.ItemTemplate> </ComboBox>
babongita
Posts
-
Problem with WPF Combobox -
Problem with WPF ComboboxI have a combobox where the ItemsSource is bound to a ObservableCollection and the SelectedItem is bound to a string DependencyProperty. The ObservableCollection is populated so that the first string is an string.empty, so that something by default is not selected. My problem is this, if I select something in the combobox beside the string.empty (by clicking the drop down arrow and left clicking on an item, you can click the drop down arrow and select the string.empty item. However you can use the scroll on the mouse and select the string.empty. Then the caveat is that you can not scroll with the mouse to something that is not string.empty, you have to hit the drop down arrow and select an item with a left mouse click. Any ideas, this has me stumped.
-
WPF Combobox databindingOK I have finally figured it out, but it really is a different work around. Or at least it seems like it. If instead of creating the ParameterName objects with all of the properties associated with it, if I only create a collection of strings and then bind them to the dropdown box then I can make the binding work. But it is not the object itself it is only one piece of the object.
-
WPF Combobox databindingOK I am going back through now and trying you recommendations and this is the error that I am getting in the Output window System.Windows.Data Error: 39 : BindingExpression path error: 'Name' property not found on 'object' ''ParameterName' (HashCode=62178992)'. BindingExpression:Path=Name.ParameterDisplayName; DataItem='ParameterName' (HashCode=62178992); target element is 'ComboBox' (Name='cboParameterName'); target property is 'NoTarget' (type 'Object')
-
WPF Combobox databindingOK well I modified that post. But is it possible that we could continue this offline?
-
WPF Combobox databindingI was thinking about binding to the ListView but the problem I had was that the user has the option to Add/Edit/Remove (all buttons on the view) a parameter, and I couldn't figure out how to add a new parameter and still have it be bound. Does that make sense? Can I email you offline? I would like to discuss this offline with some screen shots of what I am trying to duplicate.
modified on Friday, March 6, 2009 12:46 PM
-
WPF Combobox databindingI didn't check the output window to see what was happening. When I hit the dropdown on the combo I couldn't see anything in it, but the itemsource had the values. But digging into the SelectedIndex seems to be the way to go here, it is performing as expected. But like I said, I will need to get the Index each time the screen loads, since the Index may change, not often but enough that I can't rely on that being the same I guess I could create a converter for that couldn't I, then it would be more of an "automated" thing, right?
-
WPF Combobox databindingBTW, I tried your suggestion and the first problem was that the combobox wasn't showing what was loaded, the second problem was that the parameter.name wasn't being set either
-
WPF Combobox databindingI have been playing with using the SelectedIndex. And it seems to work, at least for now, the problem that I foresee is that I will have to go through the Combobox source to get the index each time, in the event that the Index would change, either by addition or substraction of Metadata. What are your thoughts on that?
-
WPF Combobox databindingFirst of all you are correct they are bound to different properties of the Parameter object. My question is though, that I am binding the ComboBox to a Collection of Classes, and the Parameter object as a property which is a the same class, so I would think that the SelectedValue should be able to bind directly to that Value, since they are of the same type. It is just instead of it being a string object, is of another type. I tried using: SelectedValue="{Binding SelectedParameter.Name.ParameterDisplayName, Mode=TwoWay}" but then the actual property doesn't get set correctly. How can I set that combobox to be the correct item then?
-
WPF Combobox databindingOK, There is a listbox below, which is bound to Collection of Parameters(this is a class, not what you would typically think of when you think parameters), then there is a "view" above it which shows the "detail" (attributes) of the SelectedItem in the listbox. All of the TextBoxes or the CheckBoxes show the "detail" (attributes) correctly. But when the "detail" (attribute) is an item in a Combobox the item doesn't show in the Combobox even though it is bound to that "detail"(attribute). The combobox is populated with all of the possible selections, but the SelectedItem, isn't shown in that combobox.
-
WPF Combobox databindingThe ParameterViewModel has an ObservableCollection ParameterNameCollection which is a collection of possible names that it could be, with attributes associated to that name, so the Collection is what fills the combobox, but I want the SelectedItem to be the ParameterName of the Parameter object. If I was to post the complete class for the ParameterViewModel it would look like this: ParameterViewModel has a ControlModeCollection (ObservableCollection) has a ControlTypeCollection (ObservableCollection) has a DataTypeCollection (ObservableCollection) has a ParameterMethodCollection (ObservableCollection) has a ParameterNameCollection (ObservableCollection) has a DP of SelectedParameter (of Type Parameter) has a DP of SelectedParameterDefaults (I think this is redundant since it is an ObservableCollection) Then the Parameter class looks like the following has a Name (of Type ParameterName) has a DataType (of Type DataType) has a ScreenLabel (of Type String) etc. etc. the TextBox XAML works as expected, the ComboBox doesn't
-
WPF Combobox databindingThere are four different view models since there is are parent child relationships in this scenario. Here is an attempt to explain TabParameterViewModel has a DP of ParameterCollection (which is of Type ObservableCollection) has a DP of Parameter (bound to the selected item in a ListView) ParameterViewModel has a DP of Parameter which is set to a clone of TabParameterViewModel.Parameter has a DP of ParameterDefaultCollection (again an ObservableCollection) this.Parameter.Defaults ParameterDefaultsViewModel has a DP of ParameterDefaultCollection bound to a ListView has a DP of ParameterDefault bound to the selectedItem in the ListView ParameterDefaultViewModel has a DP of ParameterDefault which is set to a clone of ParameterDefaultsViewModel.ParameterDefault The Parameter Model has a Name property which is a class of ParameterName, which contains other attributes that are needed for the ParameterName. It also has a string property called ParameterLabel which I have bound to a textbox, when I change the SelectedItem in the listbox int TabParameterView the corresponding attributes change in the ParameterView, but any item bound to an object (in this case a Combobox) that attribute is not populated.
-
WPF Combobox databindingYes the all of my base classes implement INotifyProperyChanged
-
WPF Combobox databindingon a side note this happens with all of the comboboxes, but I have them all coded the same so I have the same issue.
-
WPF Combobox databindingI have tried TwoWay, but that didn't fix the problem, any other ideas?
-
WPF Combobox databindingI have a combobox which loads and displays exactly how I want it to, it is in a view and I am able to retrieve the pieces from this view without any problem. The problem I have is when I throw the object back at the view the combobox(which is bound to a collection of objects) the combobox doesn't show the information. What am I missing? Here is the combobox XAML:
-
C# xsdIs there a way to write the xsd of a class object without rolling my own code to do so?
-
WPF and MVVM pattern questionSorry, Pete I did send you the code on Wednesday I used pete.ohanlon@gmail.com. I resent the code again just now, it will come from zoey.babongita@gmail.com. If you don't get it soon, please let me know, You should have two emails now, the first one being a few classes, and the second one being the entire solution. Pick your poison. Thanks
-
WPF and MVVM pattern questionHere is the XAML IsSynchronizedWithCurrentItem="True" Grid.Row="1" ItemsSource="{Binding Path=ReportScreens}" ItemTemplate="{DynamicResource ScreenTabScreen}" Margin="10,0,10,10"> And I can email any/all of the code for these areas if you would like.