草庐IT

android-viewmodel

全部标签

c# - 将 ListView 的 SelectedItems 绑定(bind)到 ViewModel

我有一个ListView,它将项目与View模型中的属性绑定(bind)。在View模型中。ICollectionView_businessCollectionpublicICollectionViewBusinessCollection{get{return_businessCollection;}set{_businessCollection=value;RaisePropertyOnChange("BusinessCollection");}}如何在View模型中获取选中的businesscollection项? 最佳答案 1

c# - 如何在没有代码隐藏的情况下处理我的 ViewModel 中的 WPF 路由命令?

根据我对MVVM的理解,直接在ViewModel中处理路由命令是一种很好的做法。当路由命令在ViewModel中定义为RelayCommand(或DelegateCommand)时,很容易像这样直接绑定(bind)到命令:Command={BindingMyViewModelDefinedCommand}。实际上,对于在我的ViewModel外部定义的路由命令,我在View的代码隐藏中处理这些命令并将调用转发到ViewModel。但我觉得我不得不这样做很尴尬。它违背了推荐的MVVM良好实践。我认为应该有一种更优雅的方式来完成这项工作。如何直接在ViewModel中处理“System.W

c# - Caliburn.Micro 无法匹配来自不同程序集的 View 和 ViewModel

我刚开始使用Caliburn.Micro。我正在尝试引导我的简单示例解决方案,将ShellView(用户控件)放在Test.App程序集中,并将ShellViewModel放在Test.ViewModel程序集中。我得到的是一个带有以下文本的窗口:“找不到Caliburn.Test.ViewModel.ShellViewModel的View”。但如果我将ViewModel移动到.App程序集,它会完美运行。这是Caliburn.Micro.Test程序集(可执行)中的Bootstraper:namespaceCaliburn.Micro.Test{publicclassAppBoots

c# - SelectLists 属于 viewModels 吗?

看完这个问题ASP.NETMVC:NestingViewModelswithineachother,antipatternorno?和DerickBailey的评论ithinkthe"considerwhatyourviewmodelwouldlooklikeasxmlorjson"bitisprobablythemostimportantpoint,here.ioftenusethatperspectivetohelpmeunderstandwhattheviewmodelshouldlooklike,andtohelpmeunderstandwhatdatais"viewmodel

c# - 在 Android (Xamarin) 上实现 Office 365 API 的问题

我试图让这个应用程序作为起点运行。https://medium.com/xamarin-development/integrating-office-365-into-xamarin-apps-f9a33e5c73b1.我设置了一个试用帐户,输入了客户端ID等。当我尝试输入凭据以登录我的工作Office365帐户或单独的outlook.com帐户时,我在调试输出中收到以下错误,Refusedtoexecutescriptfrom'https://directory.services.live.com***'becauseitsMIMEtype('application/json')is

c# - 我能以某种方式告诉 Resharper ViewModel 的类型吗?

我们在不同的程序集中有Views和ViewModels。View的程序集具有对VM的引用。(有时我们需要隐藏代码)。ViewModel的DataContext是在代码中设置的,而不是在XAML中。因此,无论是VS还是Resharper都无法像智能感知那样提供帮助,Resharper也会给出很多警告。我们是否可以在XAML注释中为Resharper设置任何指令,以表明我们打算将View与特定类型的VM一起使用?更新:不错blogpost作为已接受答案的补充。 最佳答案 我遇到了同样的问题,并通过使用XAML中的设计时支持在XAML编辑

c# - 加载程序集 Xamarin.Android.Support.v4 时出现异常

我正在使用Xamarin.Forms开发visualstudio,我收到以下错误:Exceptionwhileloadingassemblies:System.IO.FileNotFoundException:Couldnotloadassembly'Xamarin.Android.Support.v4,Version=1.0.0.0,Culture=neutral,PublicKeyToken='.Perhapsitdoesn'texistintheMonoforAndroidprofile?Filename:'Xamarin.Android.Support.v4.dll'atXam

c# - Prism,将 Views 和 ViewModels 与 Unity 连接起来,试图理解它

CreatingtheViewandViewModelUsingUnityUsingUnityasyourdependencyinjectioncontainerissimilartousingMEF,andbothproperty-basedandconstructor-basedinjectionaresupported.Theprincipaldifferenceisthatthetypesaretypicallynotimplicitlydiscoveredatruntime;instead,theyhavetoberegisteredwiththecontainer.Typi

c# - XAML 中的命令绑定(bind)与 ViewModel 中的 ICommand 属性

我刚刚开始在应用程序中使用MVVM命令。我找到了许多示例,并在我的代码中尝试了两种方法。一些示例在xaml中具有命令绑定(bind),如下所示:...OpenRecentFile_Executed是ViewModel中的一个方法和一个静态ICommand,如下所示:publicstaticreadonlyICommandOpenRecentFile=newRoutedCommand("OpenRecent",typeof(MainWindow));我还看到ViewModel上有一个ICommand类型的属性在View中绑定(bind)到,如下所示:在ViewModel中:private

c# - WPF MVVM Light 单元测试 ViewModels

我不是MVVM模式的常客,这基本上是我第一次使用它。我过去所做的(“普通”WPF)是使用业务层和数据层(通常包含由服务或EntityFramework创建的实体)创建我的View。现在经过一番尝试后,我从MVVMLight创建了一个标准模板并执行了以下操作:定位器:publicclassViewModelLocator{staticViewModelLocator(){ServiceLocator.SetLocatorProvider(()=>SimpleIoc.Default);if(ViewModelBase.IsInDesignModeStatic){SimpleIoc.Defa