2014-03-27 30 views
0

我想结合我设计数据在电网单个属性(保证金)。我不希望覆盖数据上下文网格作为一个整体(也使用设计数据如何DesignData结合到单一物业

<Grid 
    d:DataContext="{d:DesignData Source=/Blend/DesignData/HudDesignData.xaml}" 
    Margin="{Binding Source={d:DesignData Source=/Blend/DesignData/WPFSplitScreenLayoutDesignData.xaml}}"> 

设计数据被设置为DataContext的按预期工作。

d:DataContext="{d:DesignData Source=/Blend/DesignData/HudDesignData.xaml}" 

但是,我想不出如何分配设计数据直接保证金的绑定源。

Margin="{Binding Source={d:DesignData Source=/Blend/DesignData/WPFSplitScreenLayoutDesignData}}" 

上面的行给出以下错误:

Error 1 The tag 'DesignData' does not exist in XML namespace ' http://schemas.microsoft.com/expression/blend/2008 '. Line 13 Position 135.

谢谢!

回答

0

你是否错过了wpfsplitscreenlayotudesigndata的.xaml?

或者您将边距绑定到视图模型 上的属性,然后从视图模型中找到所需的wpfsplitscreenlayoutdesigndata。

Margin="{Binding Path = someint}" 

int someint 
{ 
    get 
    { 
     //return the wpfspliscreenlayoutdesigndata which I assume you are getting from the visual tree 
    } 
} 
+0

缺少.xaml是一个错字。固定。 我不认为你的建议会起作用,因为设计数据的要点是在不影响运行时的情况下具有“设计时间”特定数据。在你的例子中,你正在改变Margin的运行时绑定。 – Goose

+0

Margin =“{Binding Source = {d:DesignData Source =/Blend/DesignData/WPFSplitScreenLayoutDesignData.xaml},RelativeSource = {RelativeSource FindAncestor,AncestorType = {x:Type Window}}}” Give a a go – Chris