windows phone 设计时 数据源

    <Grid x:Name="LayoutRoot" Style="{StaticResource FirstButtonStyle}" >
        <Grid.Background>
            <ImageBrush Stretch="None"/>
        </Grid.Background>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Canvas HorizontalAlignment="Left" Height="766" Margin="0,2,0,0" Grid.RowSpan="2" VerticalAlignment="Top" Width="480">
            <Grid Height="53" Canvas.Left="70" Canvas.Top="10" Width="225"/>
            <Button Content="Button" Style="{StaticResource XingButtonStyle}" Canvas.Left="56" Canvas.Top="128" Template="{StaticResource ddd}"/>
            <ListBox Height="390" ItemTemplate="{StaticResource ItemTemplate}" d:DataContext="{Binding Source={StaticResource SampleDataSource}}" ItemsSource="{Binding Collection}" Canvas.Left="40" Canvas.Top="88" Width="395"/>
        </Canvas>

    </Grid>

重点是  d:DataContext="{Binding Source={StaticResource SampleDataSource}}" ItemsSource="{Binding Collection}"

 

还有designInstance

xmlns:local="clr-namespace:PhoneApp6" (引入model数据所在的命名空间)

d:DataContext="{d:DesignInstance Type=local:ViewModels, IsDesignTimeCreatable=True}"  d:DesignInstance 实例化   
IsDesignTimeCreatable=True 设计时可见

 


 

相关链接:http://msdn.microsoft.com/zh-cn/library/ff602277(v=vs.95).aspx

posted @ 2013-04-24 17:50  蝗虫的大腿  阅读(321)  评论(0编辑  收藏  举报