locked
Bug in Blend 3 RC | Unable to resolve a static class | designer exception RRS feed

  • Question

  • To reproduce the issue:
    1- Create a new WPF project in Blend 3
    2- Copy and paste the following C# code as a new class:

     public static class LookupTablesCache
     {
      public static string Abc;
     }

    3- Open the Window1 Xaml and copy and paste the following xaml:

    <Window.Resources>
    <DataTemplate>
      <TextBox Margin="142,116,236,0" VerticalAlignment="Top" Height="40"  TextWrapping="Wrap"
      Text="{Binding Source={x:Static test:LookupTablesCache.Abc}}"/>
    </DataTemplate>
    </Window.Resources>

     <Grid x:Name="LayoutRoot">
      <TextBox Margin="142,116,236,0" VerticalAlignment="Top" Height="40"  TextWrapping="Wrap"
      Text="{Binding Source={x:Static test:LookupTablesCache.Abc}}"/>
     </Grid>

    You will notice a link under the first “x:Static test:LookupTablesCache.Abc” saying invalid xaml, while the second one will work with no problems

    Expected results:
    The designer must be able to resolve the x:static markup when in the data template, the xaml is correct, the blend 3 designer is not able to resolve it.
    We also noticed a problem with the images in nested templates, the designer tries to load the images from blend.exe instead of the application, it looks like the data templates are treated internally in a different way.

     

    Friday, July 10, 2009 1:48 PM

All replies

  • When trying to run this project, we get the following exception. Are you sure this is something that works fine at runtime?

    XamlParseException: Cannot convert the value in attribute 'Source' to object of type 'System.Windows.Markup.StaticExtension'.  Error at object 'System.Windows.Data.Binding' in markup file 'WpfApplication3;component/mainwindow.xaml' Line 19 Position 3.

    Thanks,
    Unni
    This posting is provided "AS IS" with no warranties, and confers no rights.
    Friday, July 10, 2009 6:15 PM
  • Hi

    The text is not initialized, the code above is the minimum possible code to reproduce the problem, and here is the entire code:

    <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            x:Class="WpfApplication3.MainWindow" xmlns:frmk="clr-namespace:WpfApplication3" x:Name="Window" >
        <Window.Resources>
            <DataTemplate x:Key="abc">
                <TextBlock Text="{Binding Source={x:Static frmk:LookupTablesCache.Abc}}" />
            </DataTemplate>
        </Window.Resources>
        <Grid x:Name="LayoutRoot">
            <TextBlock Text="{Binding Source={x:Static frmk:LookupTablesCache.Abc}}" />
        </Grid>
    </Window>
     

    and C#


    namespace WpfApplication3
    {
     public partial class MainWindow : Window
     {
      public MainWindow()
      {
                LookupTablesCache.Abc = "test";
       this.InitializeComponent();           
      }
     }
        public static class LookupTablesCache
     {
            public static string Abc;
     }
    }

    We noticed this issue in our project with expression blend 3, our project uses a static class for the lockup tables,  and the xaml is split in to data templates, the data templates are fine, just blend for some reason thinks it is an error.
    Saturday, July 11, 2009 2:47 PM
  • Thanks, I can repro this now and will file a bug to track this. Unfortunately, we won't be able to fix this issue for Blend 3 but fix it for a future release.

    Thanks,
    Unni
    This posting is provided "AS IS" with no warranties, and confers no rights.
    Saturday, July 11, 2009 7:06 PM