d:DataContext="{d:DesignInstance viewModel:ContactViewModel}"

 

这样再xaml里面写binding 能联想出来

 http://technet.microsoft.com/zh-CN/library/ee839627(v=vs.100)

WPF 设计器提供下列设计时特性。

 

设计时特性

说明

示例用法

d:DesignHeight

在您单击根大小标记 () 时自动增加。

<Window x:Class="DesignDataDemo.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:DesignDataDemo"
        Title="MainWindow" mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" d:DesignHeight="350" d:DesignWidth="525" SizeToContent="WidthAndHeight">


d:DesignWidth

在您单击根大小标记 () 时自动增加。

<Window x:Class="DesignDataDemo.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:DesignDataDemo"
        Title="MainWindow" mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" d:DesignHeight="350" d:DesignWidth="525" SizeToContent="WidthAndHeight">


d:DataContext

演练:使用 WPF 设计器创建数据绑定

<Grid d:DataContext="{d:DesignInstance Type=local:Customer}" Name="_grid">


d:DesignInstance

演练:在设计器中使用 DesignInstance 绑定到数据

<Grid d:DataContext="{d:DesignInstance Type=local:Customer}" Name="_grid">


d:DesignData

演练:使用 WPF 设计器中的示例数据

<StackPanel d:DataContext="{d:DesignData Source=./DesignData/SampleCustomer.xaml}" Grid.Row="0"></StackPanel>


d:DesignSource

这样便可使用数据绑定生成器创建绑定。

 
<CollectionViewSource x:Key="CustomerViewSource" d:DesignSource="{d:DesignInstance local:Customer, CreateList=True}" /> 

d:IsDesignTimeCreatable

d:DesignInstance 标记扩展中,指定根据您的类型创建设计实例,而非设计器生成的替代类型。

 
<Grid d:DataContext="{d:DesignInstance local:Customer, IsDesignTimeCreatable=True}">

d:CreateList

d:DesignInstance 标记扩展中,指定设计实例是指定类型的列表。

 
<CollectionViewSource x:Key="CustomerViewSource" d:DesignSource="{d:DesignInstance local:Customer, CreateList=True}" />

d:Type

d:IsDesignTimeCreatable 可以指定是创建某一实例或您的类型还是设计器生成的替代类型。

 
<CollectionViewSource x:Key="CustomerViewSource" d:DesignSource="{d:DesignInstance Type=local:Customer, CreateList=True}" />

MainWindow 右下角处的根大小标记 () 时,系统会自动映射命名空间。

演练:使用 WPF 设计器中的示例数据

 

生成操作

说明

DesignData

可以为只读属性赋值。

DesignDataWithDesignTimeCreatableTypes

您所用的类型在 XAML 中必须是可创建的。

相关文章:

  • 2021-11-22
  • 2021-07-10
  • 2022-12-23
  • 2022-12-23
  • 2022-02-13
  • 2022-02-23
  • 2021-12-04
猜你喜欢
  • 2021-10-14
  • 2022-12-23
  • 2021-09-17
  • 2022-02-26
  • 2021-10-23
  • 2021-12-23
相关资源
相似解决方案