locked
Design-time binding with a Source set to StaticResource

    Question

  • I have the resource defined in App.xaml like this  <vms:GlobalView x:Key="GlobalView"/>, it loads sample data instead of real data just fine at design time (I have checked it by inserting "throw new Exception()" to the code and watching XAML designer crash).

    The question is why 

    <TextBlock Text="{Binding Game.Test, Source={StaticResource GlobalView}}" FontSize="72"></TextBlock>

    fails at design-time while

    <Grid DataContext="{StaticResource GlobalView}">
             <TextBlock Text="{Binding Game.Test}" FontSize="72"></TextBlock>
            </Grid>

    works.

    Both code work fine at runtime.

    I can workaround it easy by using CollectionViewSource, d:Source and d:DesignInstance, just curious why it works like that.

    Friday, September 14, 2012 5:57 PM

Answers

  • I've sent a repro, but it's probably not a bug. I've used a highly unusual approach of managing design-time data, relying on order of object instantiation in App.xaml, I've merged my two classes to one and it works now at design-time too.
    • Marked as answer by Dzugaru Sunday, September 16, 2012 2:10 PM
    Sunday, September 16, 2012 2:09 PM

All replies

  • That is indeed surprising, and might be a bug. Could you please send me your repro at unnir at Microsoft dot com, and I will make sure it is fixed.

    Thanks!


    Unni Ravindranathan, Program Manager, Microsoft Expression This posting is provided "AS IS" with no warranties, and confers no rights.

    Saturday, September 15, 2012 6:02 PM
  • I've sent a repro, but it's probably not a bug. I've used a highly unusual approach of managing design-time data, relying on order of object instantiation in App.xaml, I've merged my two classes to one and it works now at design-time too.
    • Marked as answer by Dzugaru Sunday, September 16, 2012 2:10 PM
    Sunday, September 16, 2012 2:09 PM