Calling something a ViewModel is just arguing semantics. Its just some random (generally observable) object that the DataContext points to. In the MVVM world its just some random (always observable) object that derives from "ViewModelBase" or something similiar.
The VM that owns the listbox would have the ObservableCollection<Section>. Section would then contain the VM / whatever for the UserControl.
I created a user control and I want to display it as the content of a combobox.
I tried to wire up the user control inside the combo, but I see nothing, and the user control's view model isn't being instantiated.
JobListView is a custom tree with search conntrols. How do I make the ComboBox use the JobListView as its content? Right now, when I run it and open the combo, nothing appears.
Why would it show anything? Think about what your XAML is doing. You set the ComboBox.ItemTemplate to show a views:JobListView. You just said "I want to render each item (in both the edit box and the drop down list) as a views:JobListView". So, if you have 10 items, you are going to get 10 views:JobListView plus another one in the edit box. Probably not what you meant .
As I have mentioned to you in the past, you really need to aquire a tool that will allow you to dump out control templates, so you understand how they are put together so you can do these types of mods as you get more advanced.
I would highly recommend you install Expression Blend Preview since its now free and allows you to dump out control templates easily as well as modify them visually.
Also, in your response to the other guy, you said you didn't set the combo box ItemsSource to anything and wanted the JobListView to retrieve everything. That won't work on a conceptual level. How is the edit box in the combo box going to display the selected item when it knows nothing about the collection?
You need to have the VM that owns the combo box own the collection and set the combo box ItemsSource to it. The edit box will show the selected item and the popup view will render as your JobListView.
I'm not going to post the ComboBox control template here since its quite large (200+ lines of XAML), but I did dump it out for discussion purposes.
There isn't an easy way to style the drop down list because its essentially an ItemsPresenter and doesn't have any built in templates for that.
You *might* be able to wait for the combo box template to be applied and then find the "DropDownScrollViewer" control by name and replace its content with your control. I haven't tried this, so its possible it won't work. If I was doing this task, I'd probably try it first though. Otherwise, it looks like you are going to have to dump out the control template and replace the ItemsPresenter with your joblistview.
There's your problem - your control is only ever using a single instance of the WebBrowser control, no matter how many instances of your control you create.
It looks like the only reason you've made it static is so that you can access it from the DependencyPropertyChanged events. All you need to do is cast the DependencyObject parameter to your ExtWebBrowser class, and you'll be able to access non-static fields, properties, and methods.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
Hi there i have recently decided that i wanted to start playing around with app development. I was woundering if anyone can point me to any good information sources for such task. I dont know any xaml or silverlight so im learning from the ground up. Any books you can recommened, web sites, anything really.
I want a StackPanel to be populated by one button for each entry in an ArrayList. I can set up these buttons from the ArrayList using a foreach sequence. But how would I define the corresponding event handlers?
Each button calls the same event (Command) and passes in the commandparameter which should be bound to the object in the collection. So the method receives and object that can then be cast as the item in the collection.
Never underestimate the power of human stupidity
I'm struggling to get my MVVM WPF app to work with a set of Tasks updating the UI.
I've got a Command that starts X number of tasks off, for each task I'd like the UI to update when started and when finished. I've also got a second Command to cancel the task, which I'd obviously like working (the code does but as the UI locks the button doesn't)
I've used a ListBox bound to an ObvservableCollection<string> for the results, as this seemed better than binding to a string.
At the moment I get the UI lockup until all tasks are finished. This is with or without a Task.WaitAll. The results are correct, the tasks don't always start/finish in the same order so they're obviously being generated and updating the collection asynchronously.
I've tried an AysncObservableCollection (as per this SO answer)
I've tried using the Dispatcher in my method that adds a item to the collection.
I've tried variations on the Binding parameters.
Can someone give me some hints Surely people have created a status log with async stuff in MVVM before??
Do I need to move the task creation to the Model?
I've seen mention of making sure the Collection is initiated on/by the View, not sure I understand that!
The View has a DataContext that's set to my ViewModel. Do they mean I've got to create the Collection in the code behind of the View? that doesn't seem right.
Oh this is .NET4.0 on XP, and I'm not using any MVVM frameworks (didn't think that was a good idea as I'm still learning)
How are you binding the ListBox and ObservableCollection<string>?
Are you creating the ObservableCollection in the ViewModel?
Is it bound to the ItemsSource on the ListBox?
If you can show some of the code/xaml we can provide more assistance.
Last Visit: 31-Dec-99 18:00 Last Update: 20-May-22 19:20