我将我的应用程序升级到MvvmCross 6.0版.现在它可以进入启动画面并且不做任何其他事情.通过查看控制台,我可以看到服务正在启动.这是我的app.cs:
public class App : MvxApplication
{
public override void Initialize()
{
MPS.ApplicationName = Settings.ApplicationName;
EventLog.ApplicationName = Settings.ApplicationName;
BlobCache.ApplicationName = Settings.ApplicationName;
CreatableTypes()
.EndingWith("Service")
.AsInterfaces()
.RegisterAsLazySingleton();
CreatableTypes()
.EndingWith("Singleton")
.AsInterfaces()
.RegisterAsSingleton();
//RegisterAppStart(new CustomAppStart());
//RegisterNavigationServiceAppStart<LoginViewModel>();
RegisterAppStart<LoginViewModel>();
}
}
Run Code Online (Sandbox Code Playgroud)
这是非常基本的.我已经转换为新的导航系统因此RegisterNavigationServiceAppStart.那将不再解决,所以我回到了直接的RegisterAppStart.启动画面出现然后停止.如果重要,splashscreen.cs如下:
[Activity(
Label = "@string/ApplicationName"
, MainLauncher = true
, Icon = "@drawable/icon"
, Theme = "@style/Theme.Splash"
, NoHistory = true)]
//, ScreenOrientation = ScreenOrientation.Landscape)]
public class SplashScreen : MvxSplashScreenActivity
{
public SplashScreen()
: base(Resource.Layout.SplashScreen)
{
}
}
Run Code Online (Sandbox Code Playgroud)
这很香草,但我知道事情已经发生了变化.我的setup.cs如下:
public class Setup : MvxAndroidSetup …
Run Code Online (Sandbox Code Playgroud) 我一直在使用MvvMCross一段时间,这段代码一直在运行.我确实安装了最新的更新,但我不能发誓这是问题开始的时候.发生的事情是我有一个登录屏幕,其中包含对用户名和密码的简单文本绑定.当我使用Use Shared Runtime编译时,它工作正常.如果未选中此选项,则不会将文本绑定到文本字段.我的布局如下:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:layout_width="250dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="center_horizontal"
android:layout_marginTop="50dp"
android:background="@drawable/borderdoublewidth">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
style="@style/InputTextView"
android:text="User Name" />
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/txtUserName"
style="@style/InputEditText"
local:MvxBind="Text UserName" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
style="@style/InputTextView"
android:text="Password" />
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/txtPassword"
android:inputType="textPassword"
android:password="true"
style="@style/InputEditText"
local:MvxBind="Text Password" />
</LinearLayout>
<Button
android:text="Login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
local:MvxBind="Click CheckLogin" />
</LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我的视图模型如下:
class LoginViewModel : MvxViewModel
{
public void Init()
{
} …
Run Code Online (Sandbox Code Playgroud) 具体来说,在执行自动完成时,在VB中,您可以键入并意识到您在错误的路径上,然后退格并再次开始键入并显示自动完成建议.这与TSQL的工作方式相同.在C#中如果发生这种情况,您必须退回到对象上的句点,以便Intellisense在您开始退格后重新启动.在某些情况下,C#中的退格不会禁用智能感知,但我认为一旦你选择了某些东西,智能感知就会退出,直到你回到这个时期.有没有设置或修复?
这个问题过去曾问过,这里的答案/sf/answers/3166558111/对我来说是一个救星。问题是当我迁移到 .Net Core 3.0 时,它坏了。原因可以在这里找到https://github.com/aspnet/AspNetCore/issues/8678。简而言之,Microsoft 将一些函数公开在一个标记为 internal 的类中。修复此已删除对 ExpressionMetadataProvider 的访问。考虑以下 HTML 帮助程序
using Microsoft.AspNetCore.Mvc.ViewFeatures.Internal;
public static class MvcHtmlHelpers
{
private static IHtmlContent MetaDataFor<TModel, TValue>(this IHtmlHelper<TModel> html,
Expression<Func<TModel, TValue>> expression,
Func<ModelMetadata, string> property)
{
if (html == null) throw new ArgumentNullException(nameof(html));
if (expression == null) throw new ArgumentNullException(nameof(expression));
var modelExplorer = ExpressionMetadataProvider.FromLambdaExpression(expression, html.ViewData, html.MetadataProvider);
if (modelExplorer == null) throw new InvalidOperationException($"Failed to get model explorer for {ExpressionHelper.GetExpressionText(expression)}");
return new HtmlString(property(modelExplorer.Metadata));
}
public static IHtmlContent DescriptionFor<TModel, TValue>(this IHtmlHelper<TModel> …
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用MvxDialogFragment从活动显示数据绑定对话框。我的对话框ViewModel如下:
public class ContainerDialogViewModel : MvxViewModel
{
public string ShipperName;
public void Init(string Name)
{
ShipperName = Name;
LoadData();
}
public void LoadData()
{
Survey = SurveyDataSource.CurrSurvey;
}
private ShipmentSurvey _Survey;
public ShipmentSurvey Survey
{
get
{
return _Survey;
}
set
{
_Survey = value;
RaisePropertyChanged(() => Survey);
RaisePropertyChanged(() => Containers);
}
}
public List<ShipmentSurveyContainer> Containers
{
get
{
if (Survey == null)
return new List<ShipmentSurveyContainer>();
else
return Survey.SurveyContainers.ToList();
}
}
}
Run Code Online (Sandbox Code Playgroud)
MvxDialogFragment的编码如下:
public class ContainerDialog : MvxDialogFragment<ContainerDialogViewModel>
{
public …
Run Code Online (Sandbox Code Playgroud) 在MvvmCross的第5版中,添加了一个异步的Initialize覆盖,您可以在其中进行大量数据加载.
public override async Task Initialize()
{
MyObject = await GetObject();
}
Run Code Online (Sandbox Code Playgroud)
有没有办法在View中确定Initialize已经完成?在视图中说我想将工具栏标题设置为在MyObject中显示一个字段
MyViewModel vm;
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
// Create your application here
this.SetContentView(Resource.Layout.MyView);
var toolbar = (Toolbar)FindViewById(Resource.Id.toolbar);
SetSupportActionBar(toolbar);
vm = (MyViewModel)this.ViewModel;
SupportActionBar.Title = vm.MyObject.Name;
}
Run Code Online (Sandbox Code Playgroud)
在设置SupportActionBar.Title的行上,有没有办法确定Initialize任务是否已完成,如果没有,会收到通知吗?
更新:我尝试设置两个正确答案,因为@nmilcoff回答了我的实际问题,而@Trevor Balcom向我展示了一个更好的方法来做我想要的.
我有一个 Xamarin Android 应用程序,我需要在其中检查 VersionName。这是函数调用:
var appVersion = PackageManager.GetPackageInfo(PackageName, 0).VersionName;
Run Code Online (Sandbox Code Playgroud)
它一直运行良好。在最新的 Android 操作系统更新中,函数调用突然被弃用了。我不想使用 Xamarin Essentials。这样做迫使我使用旧的 Nuget 包。有谁知道未来在 Xamarin 中获取版本名称的首选方法是什么?
谢谢,吉姆
我需要导航到最终包含.pdf文件的网站,我想在本地保存该文件.我正在使用CEFSharp来做到这一点.此站点的性质是,一旦.pdf出现在浏览器中,就无法再次访问它.出于这个原因,我想知道一旦你在浏览器中显示.pdf,有没有办法在缓存中访问该文件的源?
我尝试过实现IDownloadHandler,但是你必须单击嵌入式.pdf上的保存按钮.我试图解决这个问题.