你能用Powershell和WPF实现模型-视图-视图模型吗?

[英]Can you implement Model-View-ViewModel using Powershell and WPF using PowerBoots?


Are there any examples of this? I haven't been able to find anything on google that shows how to implement this design practice using powerboots.

有这样的例子吗?我还没有在谷歌上找到任何显示如何使用powerboots实现这个设计实践的内容。

1 个解决方案

#1


0  

Well, I would have to work at that a bit to put together a real example, but let me give you a couple of hints to help you on your way ...

好吧,我得花点功夫来总结一个真实的例子,但是让我给你一些提示来帮助你。

  1. You should work with the current source-control "tip" of PowerBoots, the dev keeps neglecting to release, but the code is solid (one downside: I think the current tip only has the dll for .Net4 64bit)

    您应该使用PowerBoots的当前源代码控制“提示”,开发人员一直忽略了发布,但是代码是可靠的(一个缺点是:我认为当前提示只有.Net4 64bit的dll)

  2. You should consider using multiple windows in succession, or using pages to handle your "views"

    您应该考虑连续使用多个窗口,或者使用页面来处理“视图”

With the latest version from source control, you can get away with something as simple as this:

有了源代码控制的最新版本,您就可以轻松完成如下操作:

# Create a ViewModel from your data (I'm hardcoding the data):
$data = new-object psobject -property @{ 
    Name = "John Brown"
    Age = 15
    HairColor = "Black"
}

# Create a View bound to that data ...
boots { 
  stackpanel -Margin 5 { 
    textbox -text { binding -path "Name" $data }
    textbox -text { binding -path "Age" $data }
    textbox -text { binding -path "HairColor" $data }
    button "OK" -margin 10 -On_Click { $this.Parent.Parent.Close() }
  }
}

# When that closes, any changes to the data are preserved ...
$data

Obviously that's not a full MVVM example, but hopefully it will get you on your way for now.

显然,这不是一个完整的MVVM示例,但希望它能让您在目前的道路上。

智能推荐

注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:http://www.silva-art.net/blog/2010/09/08/54e2f2a544052538efa6b289cd437566.html



 
© 2014-2019 ITdaan.com 粤ICP备14056181号  

赞助商广告