Problems with Designtime Data

4 posts, 0 answers
  1. ManniAT
    ManniAT avatar
    877 posts
    Member since:
    Nov 2003

    Posted 28 Jul 2009 Link to this post

    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
  2. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 30 Jul 2009 Link to this post

    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.
  3. UI for WPF is Visual Studio 2017 Ready
  4. ManniAT
    ManniAT avatar
    877 posts
    Member since:
    Nov 2003

    Posted 31 Jul 2009 Link to this post

    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
  5. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 31 Jul 2009 Link to this post

    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.
Back to Top