I'm currently developing a WPF application using the MVVM framework. And I have this functionality:
I have a main window which has a combo box and frame (where I put my pages) and a view model. One of the pages in that frame is where a user can add a data and these data are used to populate the combo box in the main window. My problem is how to automatically update the items in the combo box after adding a data from that page. Btw, this page has a different view model too.
Thanks.
You can establish an event in the page viewmodel for changed data. Then subscribe to those events within the window viewmodel and update the combobox items accordingly.
You have access to the parent window from iframe via window.top. You have to write this code in your page what you have loaded in iFrame.
window.top.document.getElementById("combobox_element_id").value='Your New Value';
best of luck
You can pass the Source DataContext of ComboBox (ObservableCollection) to page ViewModel so you can simply modify the collection from Page view model.
Related
When using InteractionRequestTrigger for showing a custom popup view, the same instances of the View and ViewModel will be used each time it's shown. How can I recreate/reset the View/ViewModel, so the state of the View is "as default". The problem is that I use a TabControl in my popup, and the last selected tab is still selected after I close and reopen the popup.
Any ideas?
Here is method that won't require you to create a new set of nuts and bolts.
Implement IInteractionRequestAwareon your view model.
Create a integer property on the view model to store the index of the selected tab
Bind TabControl.SelectedIndex to the new property
In the implementation of the IInteractionRequestAware.Notification setter, reset the selected index property to 0.
You have to create your own PopupWindowAction. Add a property for the WindowContent Type and use that to create the new instance every time you show the popup.
I am using Xtragrid control and BindingList as data source, and CustomRowFilter event of gridView control. It works fine when I call BindingList.ResetBindings, but it resets the current selection.
Is there a way to force new filter (through CustomRowFilter event handler) without calling BindingList.ResetBindings?
Use the RefreshDataSource method to update data displayed within the grid control's View as:
//Refresh the grid control
gridControl1.RefreshDataSource();
I suggest you to go through the below reference links:
Refreshing the GridControl
GridControl.RefreshDataSource
I found solution myself:
xtraGrid.RefreshDataSource()
I am new in MVVM world. I have a question about the child window and I want some explanation. I have some collection of data and I am displaying it in the datagrid of main window. I want to select a item from collection and want to display that data in some Modal Window, Dialog or Popup. I want to edit that data and these changes should be reflected in the datagrid of main window.
Can anyone tell me what is good choice among Modal Window, Dialog and pop up. I am using MVVM Light Toolkit.
In my opinion choise between modal and non-modal window depends only on the UI experience you want to achieve. If for some reason update of the row item can't be done simultanously to other actions on the grid items you need modal one.
As described here Dialog boxes overview
A modal dialog box is displayed by a function when the function needs additional data from a user to continue. Because the function depends on the modal dialog box to gather data, the modal dialog box also prevents a user from activating other windows in the application while it remains open.
Modal dialog would be easier solution as you dont need extra validation on the row you are editing - you simply can edit one row at the time (and I assume you it wouldn't be possible to remove this row in main view while editing in edit window).
If you want to have changes done in child window reflected in your main grid, just use observable collection of items in your main view and pass certain item from this collection as a DataContext of your child window.
In an Ext Js-application I am working on I have a formpanel that contains (among other controls) three comboboxes, each with a different datastore. I need to load the form with existing data and display that in the form. This works for all simpel controls (textboxes, checkboxes) but there is a problem with the comboboxes.
The comboboxes each use a datastore but I can see that there is only one store loaded before the form loads its own data, causing that one combobox to display the correct text and the other two the value. If I click and close the combobox without making a selection the correct text appears.
Is there a way to either delay the loading of the form or the binding of the form until all datastores have loaded? The datastores are local stores with autoload and the formpanel calls its own load in the afterlayout-event.
The problem is that the setValue executed by loading your form is executed before the stores of the combo boxes are actually loaded.
You could try to implement the fix condor and animal of ExtJS have propsed in this forum thread on sencha.com: http://www.sencha.com/forum/showthread.php?75751-OPEN-42-ComboBox-s-setValue-call-with-a-remotely-loaded-Store
It basically just delays the setValue call on any combobox until the store of the combobox is fully loaded.
Load the form panel after the rendering is complete. Is there any specific reason you are loading the form in afterlayout event?
Load the form in afterrender event rather than afterlayout. the afterrender event happens when all form is completely rendered.
I'm just starting to use the composite application libraries for WPF. In my shell I have a region in a tabcontrol that is used to display different types of views. I also have a toolbar with buttons hooked up to commands, for example save. The commands are bound in my views, and the views have the canExecute and execute methods.
The idea is that when i click a tab, my tool bar buttons should be enabled or disabled according to the methods in the view. Problem is when I switch tabs the view is not getting the focus and the canExecute for that view doesn't get called. The toolbar buttons remain connected to the commands in the previously selected view, and reminds that way until i actually click on the new view
I'm stumped right now on how to force the view to get the focus. I've tried looking at the tab's content when the tabs SelectionChanged and setting the focus there but its not making a difference. Any ideas?
Try listening for the View.Loaded event, then call View.focus() in the handler. Wpf will not accept focus requests before an element is initialized and loaded. Since the SelectionChanged event is raised before the view is loaded, the focus request will just be ignored. The loaded event is called each time the element is shown after being hidden.
See this blog post for more information on focus:
http://www.julmar.com/blog/mark/PermaLink,guid,6e4769e5-a0b3-47b2-a142-6dfefd0c028e.aspx