I have a application which has a parent window with some menus on it ,when the menu clicks corresponding usercontrol is loaded inside the parent window as child.The parent window supports many usercontrols on each menu click ,the usercontrols are docked into the parent window. I have a usercontrol namely Items master from which the user can add items and save into database, I have another usercontrol which has a datagrid with a Combobox column for selectiong Items .The both user controls are docked on the parent window .When I add an Item into the Item master but that product is not available on the datagrid .How to refresh the items source of the datagrid combobox column when a new product is added ?
The quick answer is: use something like an event-aggregator to pass messages around the system when data is altered, so that each individual screen can re-load their respective data. The more important part is in designing and structuring you application to allow views to access the common data effectively. Look into something like MVVM for UI design.
Related
I am trying to achieve this look&feel in WPF.
It basically acts like a TabControl, with the tabs on the left (vertically)
The right side of the window completely changes depending on which item you have clicked on the left "nav bar":
Oculus UI
What I did:
I started doing a Custom Control. A grid with two columns, a StackPanel in the left column in which there will be a clickable button/label for every menu entry (vertically of course). A Property MenuEntries which is a List<string>.
How do I get the control to add a "tabpage" (a grid/canvas?) programmatically for every MenuEntry the user adds at design time?
How can I achieve the behavior of the TabControl during design time, i.e. the content on the right side changes as soon as the user clicks an item on the left (in the designer/editor)? (kind of like the TabControl itself?)
Is this the right approach or would you do that completely differently?
Yes, you can use TabControl for that, just set TabStripPlacement="Left", (some more details)
The whole rest: colors, margins etc is set via styles.
Also, to save you a lot of trouble, use MVVM (with some framework for WPF) for that. Set ViewModel collection as ItemsSource for the TabControl.
Then, when you select one of the tabs, the control will display the view for the selected VM.
DO NOT set TabItems in xaml for each tab, this is wrong way to go in the long run.
In C# WPF MVVM I have implemented a TabControl with observable collection and every time I click a certain button, a new tab is created. Inside every tab I want to have a data grid, so I added a data grind into a TabControl.ContentTemplate. Now I want to fill the data grid dynamically. Depending on which tab the data grid is in, I want to bind its ItemsSource to a certain list. So every tab has a data grid with a list of elements, but these elements are different depending on which tab the data grid is in. How can I make this binding?
I thought about extending the TabItem with a list of elements I want data grid to contain, but I do not know how to access the TabItem to which a specific data grid belongs to using XAML.
How can this be done?
I ended up adding a new UserControl and a corresponding ViewModel for it, and then added the crated user control inside the DataTemplate tag.
In .net project i'm working on a page which contains tab container with 3 tab panels. When i Switch between these tab panels the data is not updating. In first tab panel i have a grid view whose data should be update up on doing operations in other tabs but after doing operations in other tabs and when i return back to first tab it's showing the same results as that are displayed when the page is first loaded. I'm using object data source to bind this grid view. I want to refresh or rebind the grid view of the first tab up on returning to that tab from other tabs. I created 3 different user controls which will load for each tab and those user controls contains grid views and other controls.
it is as follows:
<asp:tabcontainer>
<asp:tabpanel1>
user control
</asp:tabpanel1>
<asp:tabpanel2>
user control
</asp:tabpanel2>
<asp:tabpanel3>
user control
</asp:tabpanel3>
</asp:tabcontainer>
Please help me to solve this problem
You need yo refresh or update the Object data source and then call rebind or Databind function of gridview on tab change event ...
I added autopostback=true to the tab container and bound data to gridview in Page_load mehtod of the corresponding tab panel user control.
I have a ListPicker (from Telerik's Rad Controls suite) in PopUp Mode (with around 200 elements) with its visibility set to Collapsed. I want to open when it when I press a button, instead of when I press the control itself.
Basically I'm asking if there's any way of programatically opening a UI element in Windows Phone (something like Control.Open() in the code behind).
The context for my question is the following:
as you know, the selected item of a list picker is displayed in the page containing the control.
users can click on this item to activate the control.
I want to display only one of the properties in the page containing the control (for example MyObject.Name instead of the entire MyObject), but I can't do this because the SelectedItem and ItemsSource need to be of the same type.
I'm thinking of styling a button to look identical to the ListPicker's selected item.
I need to open the ListPicker programatically when I click on the button, I'll bind the button's text to MyObject.Name
Alternatively, I could just do a data template for the way the list picker is displayed, but I'm not convinced it's possible.
Found the answer. It seems Telerik's List Picker allows you to set both an ItemTemplate for displaying items in the actual page, and a PopupItemTemplate for displaying items when the list is expanded. Both are Data Templates, so you can use Binding for values.
I have a (non MVVM) WPF C# application that evaluates oil and gas wells that I want to refactor to MVVM. One window shows the tabular information and another window shows the graphical rendition of the same data. Both have navigation buttons to move from well to well.
How can I have record selection changes in one window automatically change the selected record and datagrid focus in the other window using MVVM without having the ViewModels know the properties of the windows. Currently Window One shares the listview selected item property of the other Window.
You want Mode=TwoWay on your binding paths, with an INotifyPropertyChanged event on your objects. This should update every element bound to the data collection.
Check out http://msdn.microsoft.com/en-us/library/system.windows.data.bindingmode.aspx for more information on the Binding Modes as well as implementing INotifyPropertyChanged events.