DataGrid with AutoCompleteBox crashes Silverlight when scrolling - silverlight

I have a Silverlight 4 application with a DataGrid. The rows of the datagrid contain two AutoCompleteBoxes.
Whenever the DataGrid shows a scrollbar and the user scrolls the grid, the entire Silverlight plug-in will freeze and crash. When I run it from the debugger, I usually get the following error right before the freeze/crash:
"Error: Unhandled Error in Silverlight Application Code: 4009
Category: ManagedRuntimeError Message: Element is already the child of
another element."
I have seen several suggestions on possibly related issues on the silverlight.net forums, like avoiding inline item templates, but I have not yet found a working solution.
What I'm looking for is any information related to this: causes, fixes, work-arounds, methods to further analyse the cause of the problem, anything that could help.

One workaround that I'm currently testing, and that seems to work in my scenario, is to put the DataGrid inside a ScrollViewer. This effectively makes the DataGrid as high as it needs to be and delegates the scrolling to the ScrollViewer, so any DataGrid-scrolling-related problems are hereby avoided.
The only drawback I have found yet (other than that it is a very ugly workaround): the header row of the DataGrid now scrolls out of view, of course, when scrolling down.

Related

Strange rendering error in SL app... out of browser issue?

I've been working on a SL5 app for a few days. I've mostly been using a hard coded dummy data collection when styling my app's view. Everything has been working fine, but now I want to connect it to a dynamic data collection generated by my view model (using the data service technique where you have design time & real data depending on the IsInDesignTool property.
After I cleared out the control of the hard coded data and bound it to a collection in my view model. When I run it in debug mode, I see an unhandled exception being thrown in App.xaml.cs. The exception args don't say exactly what the problem is (it is simply saying "Value does not fall within the expected range" but when I look at the sender I find the following coming from the MainWindow (my app only has a single view): "Out-of-browser specific settings do not affect in-browser applications."
Further, when I try to view the MainWindow in the designer in VS, it doesn't render and instead shows an error (the rendered exception in the designer doesn't have any of my namespaces in it, just things about controls & UIElements).
I'm at a bit of a loss how to troubleshoot this. I didn't set anything for out-of-browser when building the app and since it worked with dummy data collections, why would it suddenly have this issue (seems like if I was using an out-of-browser property it would have shown up before I bound the data to the view).
Tips/pointers?
(sorry for my bad english)
I am not sure on what is happening but I saw the error "Out-of-browser specific..." when I tried to access some specific property only available to OOB while running on browser. The solution was to test if running oob before using the property:
if (Application.Current.IsRunningOutOfBrowser)
{
Application.Current.MainWindow.WindowState = WindowState.Maximized;
}
The other problem possibly is unrelated - and sometimes can be really hard to debug - one thing that helped me is to open another instance of VS and attach it to the one where you are seeing the problem. With this setup, go to your problematic View and change to "design view" - keep an eye on the Output window of the attached VS to see if some meaningful exception is shown.
I had a similar issue.
I did put a Textbox inside kind of Listbox (radPanelBar) and added
HorizontalScrollBarVisibility="Auto" to the Textbox. It seems that the textbox had problems when to show the scrollbar and when not. Adding
ScrollViewer.HorizontalScrollBarVisibility="Disabled" to the Listbox did solve it ( so, no OOB issue at all ).
I'm not entirely sure what the error was, but it wasn't at all realted to OOB. I'm using a data service approach (in design time I programatically build real data, not the Expression Blend sample data, but when not in a design tool, it uses the REST services). I started disabling a lot of things in my dynamic data and slowly added them back. Somewhere along the way my dummy data generation was fouling things up, but SL thought it was an OOB issue.

Paging in a ListBox (Panaroma Control)

I'm using the default Panorama project in Windows Phone 7.1 and want to implement some kind of paging on the the first page's mvvm ListBox items. The sample project has 16 items, but I only want to show 4 at a time (and then buttons below showing next / previous). All of this in XAML.
I've looked around quite a bit and haven't discovered a way to make this happen. Does anyone know how this can be achieved?
Judging by your question the answer shouldn't have to be WP7 specific. Having said that you could pretty much get a listbox control with paging done in silverlight and add it inside of your Panorama page.
I did find this page which shows how to do paging in silverlight with the listbox control and two buttons like you mentioned. Sorry, it's in VB but it shouldn't be difficult to transfer the logic to C#.
But like I said it's not really phone dependent to add paging because it's all xaml. So you could probably search "Paging Listbox in Silverlight" and should find something.

DevExpress PivotGrid (Silverlight) : Popup Menus don't popup

We are using DevExpress Silverlight PivotGrid (11.2.7). The problem is that none of the popups work as one would expect.
Here is the xaml code (note that all of these properties are True by default and don't need to be set)
<dxpg:PivotGridControl
x:Name="pivotGrid"
... data bindings ...
IsFieldValuePopupMenuEnabled="True"
IsHeaderMenuEnabled="True"
IsHeaderAreaMenuEnabled="True"
/>
Once the host control for the grid is shown and the data is loaded right-clicking on any of the relevant areas doesn't bring either of the popups (there are 3).
Strangely (or not so strangely) in the sample SL project provided by devex everything works as it should.
The one (significant) difference between the sample app and our project is that we are using MEF and relevant .xaps are loaded dynamically based on which user logged in and some other stuff.
We have tried a lot stuff to figure out what is wrong but haven't managed to find anything even remotely relevant. Here is what we have tried :
Adding the pivotgrid to the host tabpage in codebehind after imports have been satisfied;
Setting / resetting properties mentioned above after imports from codebehind;
Adding the control to the startup page of the project before the MEF madness kicks in;
We also tried to popup the menus manually by inheriting from the pivotgrid control, but that has not yielded much;
Enabled RedrawRegions to make sure the popup is not popping 'under'. It's not;
Any pointers or ideas would be greatly appreciated.
Regards,
Alex
It appears that this was some bug in the version we were using at the time.
After updating to 12.1 everything works like it should without any tinkering from our side.
Looks like devex guys have bugs too...who knew right :)

Winforms widget to display a grid of constantly updated numbers?

I'd like to create a Winform app (Mono support would be a huge plus) to display a grid of rapidly updating numbers, while not running into redraw problems while scrolling.
From searching around I've found:
Telerik GridView
which seems to be exactly what I want. Is the Telerik path the way to go? Or is the capability available within the standard .NET tool set? If so, which widgets should I be looking at to implement such an application?
Thanks in advance for your help!
All the Grid components from vendors are going to have performance issues if you change the attached values very very quickly. So if you need high performance you really need to create your own. If you are concerned only about flicker and the update does not need to be amazing quick then you will be fine with Telerik or indeed any other vendors Grid component.
You could consider implementing Virtual Mode on the Telerik RadGridView to overcome any performance issues you might encounter.
The demo application included with the controls contains an example of a rapidly updating grid. Although its just a small demo, if you resize the window to be smaller the scrollbar will appear and you can scroll without any redraw issues. You can access the demo under GridView -> Performance -> High Refresh.
Unfortunately, the Telerik WinForms controls aren't compatible with mono.

WPF: Drag/Drop to re-order grid and jiggle

I need to implement a grid in WPF which has squares that can be dragged/dropped to be re-ordered, but I'm not sure the best way to do it. I was thinking using an ObservableCollection of squares and a UniFormGrid but although I have experience with both WPF and drag/drop, ideally I'd like to do a kind of 'jiggle' when before the user releases the mouse. Any suggestions on a good starting point?
I also ran across these, they might be helpful, though I'm not sure about the "make space for dragged item" behavior.
http://code.google.com/p/gong-wpf-dragdrop/
which was originally on codeplex, here's part 1: http://www.codeproject.com/KB/WPF/gong-wpf-dragdrop.aspx part 2: http://www.codeproject.com/KB/WPF/gong-wpf-dragdrop-ii.aspx
I would like to know as well. (I'm looking to duplicate the behavior of tabs in chrome or safari). In searching for answers online I ran across your post.

Resources