This is a migrated thread and some comments may be shown as answers.

Problems with Designtime Data

3 Answers 103 Views
GridView
This is a migrated thread and some comments may be shown as answers.
ManniAT
Top achievements
Rank 2
ManniAT asked on 28 Jul 2009, 09:12 PM
Hi,

I'm not sure if I do something wrong or if GridView simply insist on it's own designtime data.
I create a WPF project in expression blend 3 - add a RadGridView and create some DTD.
Binding it to RadGridView brings what I expected.
But after a build - I have northwind back again.
Here is how it looks:
http://www.pp-p.net/rgriddtd/

Regards

Manfred

3 Answers, 1 is accepted

Sort by
0
Milan
Telerik team
answered on 30 Jul 2009, 10:28 AM
Hi ManniAT,

The cause of this problem is quite bizzar - for some reason the ItemsSource binding that is created sets the ItemsSource property to null once RadGridView is refreshed and at that point our internal design-time data mechanism kicks in. 

One way to eliminate this problem is to remove the binding and use the sample data source directly:

<Grid x:Name="LayoutRoot">  
        <telerik:RadGridView ItemsSource="{StaticResource SampleDataSource}" /> 
</Grid> 

Inslead of:

<Grid x:Name="LayoutRoot" DataContext="{Binding Source={StaticResource SampleDataSource}}" > 
        <telerik:RadGridView ItemsSource="{Binding}" /> 
</Grid> 

Hope this helps.

Regards,
Milan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
ManniAT
Top achievements
Rank 2
answered on 31 Jul 2009, 10:55 AM
Hi Milan,

your markup didn't work.
But anyhow - it brought me in the right direction :)
The trick which did it for me was to set the datacontext directly on the grid.
So the first grid (your suggestion) brought no data at all.
But the second grid does the things as expected:
    <Grid x:Name="LayoutRoot" Background="White"  > 
        <telerik:RadGridView Margin="8,8,63,0" d:LayoutOverrides="Width" VerticalAlignment="Top" Height="197" ItemsSource="{StaticResource MyCustomers}" /> 
        <telerik:RadGridView Margin="8,209,63,101" DataContext="{Binding Source={StaticResource MyCustomers}}" d:LayoutOverrides="Width" ItemsSource="{Binding Collection}"/>  
    </Grid> 
 

Thank you - and yes it is bizarre because from the approach (and from what I know about binding) there should be no difference (from the view of the grid) between setting the DataContext to the grid (or even page / window) or the gridview.
But it makes a difference :)

Anyhow I still guess this has something to do with RadGrid - because when I bind (for an example) with a listbox the things work.
No matter if the datacontext is on the listbox or the grid holding the listbox.
<Grid x:Name="LayoutRoot" Background="White" DataContext="{Binding Source={StaticResource MyCustomers}}"  > 
        <telerik:RadGridView Margin="8,209,63,101" DataContext="{Binding Source={StaticResource MyCustomers}}" d:LayoutOverrides="Width" ItemsSource="{Binding Collection}"/>  
        <ListBox HorizontalAlignment="Left" Margin="28,21,0,0" VerticalAlignment="Top" Width="100" Height="100" ItemTemplate="{DynamicResource ItemTemplate1}" ItemsSource="{Binding Collection}"/>  
    </Grid> 
This works for grid and lisbox.
But when I remove the datacontext from the RadGrid - I get Northwind (which means no DTD) but the listbox binds correctly.

Conclusion:
Your suggestion brought me to a workaround.
But (from my point of view) something in RadGrid Databinding works different than with "standard controls".

Regards

Manfred
0
Milan
Telerik team
answered on 31 Jul 2009, 01:35 PM
Hello ManniAT,

Thank you for the valuable feedback. We will recheck the RadGridView DTD binding and compare it to the standart controls.

Greetings,
Milan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
GridView
Asked by
ManniAT
Top achievements
Rank 2
Answers by
Milan
Telerik team
ManniAT
Top achievements
Rank 2
Share this question
or