关于WPF和VMMV的问题 [英] Question about WPF and VMMV

查看:153
本文介绍了关于WPF和VMMV的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有一个WPF项目是一个IDE,每个文档有一个标签*,我解析写在每个标签上的代码(输入)来检测变量,数组,函数等等。这是视图完成。



现在这里是我的问题,我有一个集合(Of ViewModel)存储每个标签及其数据(要访问或修改其他)应用程序的视图),我应该将View的DataContext(解析代码)绑定到Collection中的正确Item,还是应该将它的DataContext设置为新的ViewModel?



*标签实际上是放置在AvalonDock控件中的自定义视图模型:

  <   D:DockingManager     x:名称  =  DockManager    Grid.Row   =  2 < span class =code-keyword>>  
< D:DockingManager.LayoutItemContainerStyle >
< 样式 TargetType = {x:类型D:LayoutItem} >
< span class =code-leadattribute>< Setter Property =TitleValue ={ Binding 型号 名称}/>
< / 风格 >
< / D:DockingManager.LayoutItemContainerStyle >

<跨度类= 代码关键字 >< <跨度类= 代码leadattribute> d:DockingManager.LayoutItemTemplateSelector >
< SM:PaneTemplateSelector >
< SM:PaneTemplateSelector.DocumentTemplate >
< DataTemplate >
< ContentControl >
< SM:DocumentView / >
< / ContentControl >
< / DataTemplate >
<跨度类= 代码关键字>< <跨度类= 代码leadattribute> / SM:PaneTemplateSelector.DocumentTemplate <跨度类= 代码关键字>>

< / SM:PaneTemplateSelector >
< / D:Dockin gManager.LayoutItemTemplateSelector >
< / D:DockingManager >

解决方案
AvalonDock控制结合问题已经在 http://avalondock.codeplex.com解决?/ WIKIPAGE标题= AvalonDock%20Binding&安培; referringTitle =文档 [ ^ ]


So I''ve a WPF project which is an IDE with one "label"* per document, I parse the code (input) written on each "label" to detect vars, arrays, functions, etc. and this is done by the View.

Now here''s my problem, I got a collection (Of ViewModel) that store every single label and it''s data (to be accessed or modify other views of the app), should I bind the View''s DataContext (that parse the code) to the correct Item in the Collection, or should I set it''s DataContext to a new ViewModel?

*The label is actually a custom view model placed in an AvalonDock control:

<D:DockingManager x:Name="DockManager" Grid.Row="2">
    <D:DockingManager.LayoutItemContainerStyle>
        <Style TargetType="{x:Type D:LayoutItem}">
            <Setter Property="Title" Value="{Binding Model.Name}"/>
        </Style>
    </D:DockingManager.LayoutItemContainerStyle>

    <D:DockingManager.LayoutItemTemplateSelector>
        <SM:PaneTemplateSelector>
            <SM:PaneTemplateSelector.DocumentTemplate>
                <DataTemplate>
                    <ContentControl>
                        <SM:DocumentView/>
                    </ContentControl>
                </DataTemplate>
            </SM:PaneTemplateSelector.DocumentTemplate>
        </SM:PaneTemplateSelector>
    </D:DockingManager.LayoutItemTemplateSelector>
</D:DockingManager>

解决方案

AvalonDock control binding issue has been addressed at http://avalondock.codeplex.com/wikipage?title=AvalonDock%20Binding&referringTitle=Documentation[^]


这篇关于关于WPF和VMMV的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆