DesignInstance在VS2010中工作,但在Blend5中没有

时间:2011-11-24 08:38:26

标签: silverlight xaml blend design-time-data

我无法让Blend(v5)与我的DesignInstance一起正常工作。

我有一个简单的项目..

MainPage.xaml中

<UserControl x:Class="SilverlightApplication8.MainPage"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:local="clr-namespace:SilverlightApplication8"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             d:DataContext="{d:DesignInstance local:VM,IsDesignTimeCreatable=True}"
             d:DesignHeight="300"
             d:DesignWidth="400"
             mc:Ignorable="d">

    <Grid x:Name="LayoutRoot" Background="White">
        <TextBlock Text="{Binding Test}" />
    </Grid>
</UserControl>

VM.cs

public class VM
{
        public string Test
        {
            get { return "Hello World"; }
        }
}

正如所料,在我的VS2010设计师中,它显示了“Hello World”。 但是,如果我将项目加载到Blend(v5)中,则它不会显示任何内容(空白控件)。 谁能指出我做错了什么?

一个有趣的事实...... 如果我在VM.cs的ctor中添加一个断点,并附加到Blend,它会击中ctor,但是不会命中该属性。

任何指针都会受到欢迎!

1 个答案:

答案 0 :(得分:2)

这看起来像Blend 4 Silverlight 5预览中的一个错误。我遇到了同样的问题。

这里有一个帖子

http://social.expression.microsoft.com/Forums/ro-RO/blend/thread/b91286c2-c97f-4ca1-84c8-99fa144e3b8e#5d345518-1094-40f0-bfd3-c49e3d156fd0

看起来MSFT知道它。