Wpf,Unity6
程序员文章站
2022-04-30 12:27:58
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="commonservicelocator" version="1.2" targetframework="net452" />
<package id="prism" version="5.0.0" targetframework="net452" />
<package id="prism.composition" version="5.0.0" targetframework="net452" />
<package id="prism.interactivity" version="5.0.0" targetframework="net452" />
<package id="prism.mvvm" version="1.0.0" targetframework="net452" />
<package id="prism.pubsubevents" version="1.0.0" targetframework="net452" />
<package id="prism.unityextensions" version="5.0.1" targetframework="net452" />
<package id="unity" version="3.5.1404.0" targetframework="net452" />
</packages>
using microsoft.practices.prism.unityextensions; using system; using system.collections.generic; using system.linq; using system.text; using system.threading.tasks; using system.windows; using microsoft.practices.prism.modularity; using ma; using mb; namespace wpfapplication6 { public class wpfbootstrapper:unitybootstrapper { protected override dependencyobject createshell() { return container.tryresolve<shell>(); } protected override void configuremodulecatalog() { base.configuremodulecatalog(); modulecatalog modulecatalog = (modulecatalog)this.modulecatalog; modulecatalog.addmodule(typeof(modulea)); modulecatalog.addmodule(typeof(moduleb)); } protected override imodulecatalog createmodulecatalog() { return base.createmodulecatalog(); } protected override void initializeshell() { base.initializeshell(); app.current.mainwindow = (window)this.shell; app.current.mainwindow.show(); } } }
using microsoft.practices.prism.modularity; using microsoft.practices.prism.regions; using microsoft.practices.unity; using ma.views; using ma.viewmodel; namespace ma { public class modulea : imodule { private readonly iregionmanager _regionmanager; private readonly iunitycontainer _container; public modulea(iunitycontainer container,iregionmanager regionmanager) { _container = container; _regionmanager = regionmanager; } public void initialize() { _container.registertype<igetstudentlist, studentvm>(new containercontrolledlifetimemanager()); this._regionmanager.registerviewwithregion("maregion",typeof(maview)); } } }
<usercontrol x:class="ma.views.maview" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:ma.views" mc:ignorable="d" d:designheight="100" d:designwidth="300"> <grid background="red"> <datagrid x:name="dg" itemssource="{binding stulist}" autogeneratecolumns="true" borderbrush="yellow" borderthickness="5"> </datagrid> </grid> </usercontrol>
推荐阅读
-
一个基于Net Core3.0的WPF框架Hello World实例
-
如何在双向绑定的Image控件上绘制自定义标记(wpf)
-
WPF布局容器
-
[WPF自定义控件库] 给WPF一个HyperlinkButton
-
WPF中button按钮同时点击多次触发click解决方法
-
WPF下YUV播放的D3D解决方案
-
解决WPF中空域问题(Airspace issuse)
-
WPF中在摄像头视频上叠加控件的解决方案
-
WPF集合控件实现分隔符(ItemsControl Separator)
-
[WPF自定义控件库]使用TextBlockHighlightSource强化高亮的功能,以及使用TypeConverter简化调用