Hi My usercontrols placed in tabs are unloaded and loaded every time the tabs are changed.It creates some unnecessary lag in the application.I am looking for some way to fix this behavior.I know i have to subclass tabcontrol to change this behavior but how..?
You can find two different approaches to prevent this in this StackOverflow question:
WPF TabControl - how to preserve control state within tab items (MVVM pattern)
I recommend:
Keeping the WPF Tab Control from destroying its children
Related
On click of a button I need to freeze (Read Only) the entire screen even the menus / tab controls is there any possibility to do that.
Have you tried setting Application.Current.MainWindow.IsEnabled=false? That should propagate down to all other controls which have not overriden IsEnabled.
If you're looking for MVVM way: Disable WPF buttons during longer running process, the MVVM way
We have an application with StartPage.xaml, where control template for TabControl defines some grids and stack panels. There is an itemPresenter in that template in the middle of the xaml, and a stack panel below it. While it works fine for a user, MS UI automation can see only tab items inside the item presenter, and nothing else that is defined on the same level in the template.
I tried to add standard button inside a stack panel which can not be seen by MS UIA to check if that is a problem related to custom user controls we have, but that standard button is also not visible for MS UIA.
If I use Snoop, I can see all the elements from the template in a snoop's tree on the corresponding levels of template hierarchy. But MS UIA still can't find them.
What can go wrong here with controls that will prevent MS UIA from finding them on a page?
Finally I was able to detect the problem. TabControl was templated with a bunch of different controls, while AutomationPeer stayed the same which is only aware of TabItems as TabControl children.
I subclassed TabControl and overrode OnCreateAutomation to create and return my GenericAutomationPeer, which can enumerate all child UIElements of this control and voila - UIA Verify can now see that additional controls from TabControl template.
GenericAutomationPeer implementation was found here: http://www.colinsalmcorner.com/2011/11/genericautomationpeer-helping-coded-ui.html
Great thanks to the author of that article!
im a bit new to wpf.
im trying to make the acclaimed Ribbon the center for all menus and commands of my custom app
now my main window is a tabcontrol with a few major tabs: contacts, sales, appointments,expense etc.
on top of the tabcontrol is a ribbon
(pretty similar to MS Outlook)
for each tab i have different buttons that i need
(the tabs each display a different UserControl as its main content)
plus there are several buttons that should always be in the ribbon (settings, about, new appointment...)
the best would be if i can add the RibbonTabs directly in the usercontrols and somehow merge them auto-magically with the main ribbon at runtime depending on the visible tab
if thats not possible then there is something called ContextualTabGroups, but for the life of me cant find any info on how to bind/trigger the different ribbons to certain cirmcumstances/childcontrols or whatever.
if i need to call .visibilty upon load and close of each usercontrol, then theres nothing "contextual" about that
thank you very much
I have the following components in a WPF application:
(1) Window
(2) ContentPresenter in the Window that is bound to a property in the underlying ViewModel. This Property references another ViewModel.
(3) A DataTemplate for the ViewModel that will be bound to the ContentPresenter referenced above. This data template instantiates a third-party grid that displays some data.
Whenever the ContentPresenter renders the data from the DataTemplate, it takes approximately three to four seconds for the UI to render. This causes the UI to hang for the duration of the time that it takes to render the content. Since I have little to no control over how the third-party control renders itself - my question involves whether or not it is possible to render content in a way that the UI will not hang.
Please advise.
Thanks.
Chris
How many rows is the grid displaying? And how many of those rows are visible on screen?
I'm asking because it's possible that you've got a UI layout that defeats virtualization. Usually, controls that show a scrollable list of data will perform virtualization. (The built-in ListBox does this, and any 3rd party grid of tolerable quality should do the same.) This is critical for performance, because it means your UI only needs to instantiate those items that are actually visible, rather than everything in your list.
But it's relatively easy to defeat this virtualization by accident. One way is to wrap the list or grid control in a ScrollViewer. You need virtualizing controls to be able to manage their own scrolling for virtualization to work, so the scrolling needs to happen on the inside. Wrapping a control in a ScrollViewer prevents it from doing its own scrolling. Another way it can go wrong is if you plug in a different ItemsPanel. A third possibility is that your list/grid control actually needs to be told to use virtualization.
But if you're using a control that simply takes a long time to render just the stuff you need to show on screen, then there's not much you can do - you'd need to contact the control vendor, or consider using a different vendor...
I was wondering if I can have a ComboxBox with a Treeview as the selector rather than a list?
I note that there is a ComboBox.ItemsPanelTemplate, but I don't know what I need to do to get this to work?
I could build a control 'from the ground-up' with a separate TextBox, Button and TreeView in a PopUp control, but wondered if there is an easier way.
Lee
Are you just wanting the combobox for presentation purposes regarding the treeview?
Why not use a treeview as is and just trigger the display via visibility or animation from a button or control of some sort?
I am working on similar theme as we speak. I am using the Expander control from the Silverlight Toolkit with a TreeView control inside it. When an item is selected in the TreeView, it sets the Header of the Expander and then collapses the Expander.
Initial tests indicate it's OK but as I say, just started with it myself. Will let you know if I hit any stumbling blocks.