Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
315
IndexOutOfRangeException on ApplyTemplate() when XamDataGrid has its theme set
posted

I've run into an issue that I can seem to track down. I've attached a sample solution that reproduces the issue.

I'm binding a ContentControl's content to a workspace object that can change to different workspaces. I'm also creating a DataTemplate for each type of workspace so WPF knows how to render the workspace. The issue I'm running into, is when I attempt to inspect the VIsualTree of the current workspace and that workspace contains a XamDataGrid with its theme set. To inspect the VIsual Tree, I'm calling ApplyTemplate(). If one of the workspace views contains a XamDataGrid, and the XamDataGrid's Theme property is set, I start running into trouble. If I remove the Theme setting on the XamDataGrid, it works fine.

I don't beleive I'm doing anything wrong and since the only way to induce the problem (that I've seen so far) is to set a Theme on a XamGrid.

Can someone double check my sample and see if I'm doing anything wrong? Thanks!

GridThemeIssue.zip