wpf user control inside listview is becoming transparent - wpf

We are creating 8 usercontrols to show graphs of 8 patients inside a listview. The issue is that the usercontrols when zoomed-in are not totally opaque. Due to which the the items behind that usercontrol is also visible inside it. Please suggest what could be the cause.

Related

Managing lots of controls in FlowLayoutPanel

I have a C# 4.0 Winform app, the main form of which is visually divided in half: a TreeView on the left (for navigation of data) and a FlowLayoutPanel on the right. The contents of the FlowLayoutPanel changes based on user interaction (mainly with the TreeView).
The content to be shown in the FlowLayoutPanel is comparmentalized into a number of "blocks" - some are UserControls whilst others (I'm embarrassed to say) are Panels containing various Controls.
My issue is that the number of "blocks" is now too many to see in the Visual Studio form designer, and I can't make the form large enough to see them all; this makes it hard to verify how the UI will look without running it.
How can I manage the contents of the FlowLayoutPanel so that I can see all of the controls, or am I going about it wrong?
While in the designer, make sure you have AutoScroll property set to true, which will enable you to scroll the FlowLayoutPanel child controls while in the designer view.

slow page trasitions due to databinding

I am making a search app in wp7. Every record's data is bound to a user control. I have introduced an infinite loading instead giving page numbers. So when the number of instances of the UserControl is increased in the screen the transition from one page to another page (like the preview or settings pages) or coming back from that page to the current page is getting slower. I cannot change the design (infinite loading concept).
What are the ways to handle this scenario? How about changing the visibility of the controls? And reference or suggestion will be highly appreciated.
Note I tagged WPF and Silverlight because the binding happens the same way in them, expected those to have dealt with scenarios like these.
EDIT Check this question, which is asked by me. Because of having UserControl's in the listbox the vertical offset is not being maintained. So I had no option other than using ItemsControl with scrollViewer around it. ItemsControl contains a list of 5 - 6 usercontrols which intern have itemsControls inside them, I thought virtualization may not happen in such cases. Am I right?
In WPF, this is done by Virtualization
Using Virtualization, only one copy (or a few copies) of the UserControl actually gets created, and switching to another user control actually just swaps out the DataContext that the control is bound to. It doesn't actually create a new UserControl.
For example, if you have an VirtualizingStackPanel with 100,000 items, and only 10 are visible at a time, it will only render about 14 items (extra items for a scroll buffer). When you scroll, the DataContext behind those 14 controls gets changed, but the actual controls themselves will never get replaced. In contrast, a regular StackPanel would actually render 100,000 items when it gets loaded, which would dramatically decrease the performance of your application.
This question about Virtualizing an ItemsControl can probably get you going in the right direction.
Take a look at this post, I believe the solution provided by Rico is what you are looking for. :)

WPF Performance Degradation During UI Render

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...

Why WPF UserControl's performance is so difference host into WPF application and win form application?

This is my question:
I have 200,0000 Employee object(Id,Name,Job,Address) store at a database.
I read all Employee object to Empolyee[].
I create a window form application:
I create a WPF UserControl(inside ListBox),name is "wpfUserControl1".
I put "wpfUserControl1" into a window form.
I set wpfUserControl1.listBox.ItemsSource = Employee[].
Employee objects was displayed immediately.
// Performance is very good!
I create a WPF Application
I create a MainWindow object.
I put a ListBox to mainWindow.
I set listBox.ItemsSource = Employee[].
The speed of loading is very slow and occur outofmemeory exception.
// If i load 1000 objects, performance is too slow!
My doubt is :
Why same WPF UserControl was Hosted into WinFormApp and WpfApp ,it's performance difference is so big?
Could it perhaps have something to do with virtualizing? For instance, the WPF datagrid has virtualizing turned on by default, but if you place the datagrid inside a stackpanel and don't provide any width/height restrictions, then you effectively nullify virtualization since the stackpanel allows the datagrid to grow infinitely thus having to create DataGridRows for hundreds of thousands items.
I'm just guessing that the same effect might be happening with your usercontrol. In WinForms the hosting control propbably provides specific width/height restrictions and doesn't allow the usercontrol to grow infinitely. In WPF on the other hand, depending on how your WpfApp's MainWindow is defined, the usercontrol might grow infinitely.
Try setting a specific width/height for your usercontrol or mainwindow and see if the performance gets better...

WPF TabControl Memory Issues

If I have 1 tabcontrol and 2 tabitems each containing a datagrid and load them on startup of the application the memory level is normal.
If I have 2 tab controls and each tabcontrol has 1 tabitem and i load them on startup of application memory goes crazy.
What am I doing wrong?
I am loading them the exact same way in both cases the 1 of the datagrid are using in a different control.
I could be wrong but I'm guessing that it's because that if you have one tab control with 2 tabs WPF only has to draw one of the datagrids at a time but if 2 tab controls are present WPF is drawing both of the data grids at the same time so it is going to use up more memory.
Not sure though!

Resources