开发者

Binding datacontext to another viewmodel when design mode

开发者 https://www.devze.com 2023-03-14 09:18 出处:网络
I would like to bind my silverlight view to another datacontext when I\'m in design mode. With the locator pattern, I can do something like :

I would like to bind my silverlight view to another datacontext when I'm in design mode. With the locator pattern, I can do something like :

        <UserControl or Window Or Else
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d" 
DataContext="{Binding MyViewModelStatic, Source={StaticResource Locator}}"
d:DataContext="{Binding Path=My开发者_如何学PythonViewModelDesign, Source={StaticResource Locator}}">

If I'm not using this pattern and use a declarative way like this :

<UserControl.DataContext>
    <local:MyViewModel />
</UserControl.DataContext>

How can I set the d: to another viewmodel ?

Thanks in advance for any help


This should do the trick:

<d:DesignProperties.DataContext> 
    <sample:SampleViewModel /> 
</d:DesignProperties.DataContext> 
0

精彩评论

暂无评论...
验证码 换一张
取 消