C# 使用带空父项的充气。。。沙马林
我在使用Xamarin构建Android项目时遇到问题。由于某种奇怪的原因,当它到达我的ViewModel时,它似乎失败了 这是输出C# 使用带空父项的充气。。。沙马林,c#,android,xamarin,mvvmcross,C#,Android,Xamarin,Mvvmcross,我在使用Xamarin构建Android项目时遇到问题。由于某种奇怪的原因,当它到达我的ViewModel时,它似乎失败了 这是输出 06-12 11:45:00.748 D/Mono ( 3984): Searching for '_monodroid_gref_dec'. 06-12 11:45:00.758 D/Mono ( 3984): Probing '_monodroid_gref_dec'. 06-12 11:45:00.758 D/Mono ( 3984): F
06-12 11:45:00.748 D/Mono ( 3984): Searching for '_monodroid_gref_dec'.
06-12 11:45:00.758 D/Mono ( 3984): Probing '_monodroid_gref_dec'.
06-12 11:45:00.758 D/Mono ( 3984): Found as '_monodroid_gref_dec'.
06-12 11:45:00.768 D/Mono ( 3984): DllImport searching in: '__Internal' ('(null)').
06-12 11:45:00.768 D/Mono ( 3984): Searching for '_monodroid_gref_log_delete'.
06-12 11:45:00.778 D/Mono ( 3984): Probing '_monodroid_gref_log_delete'.
06-12 11:45:00.778 D/Mono ( 3984): Found as '_monodroid_gref_log_delete'.
06-12 11:45:01.397 D/Mono ( 3984): Assembly Ref addref SynchramedViewer.Droid[0x1d54f8] -> Cirrious.CrossCore.Droid[0x18f8e8]: 4
[0:]
mvx:Diagnostic: 13.50 Attempting to load new ViewModel from Intent with Extras
06-12 11:45:01.528 I/mono-stdout( 3984): mvx:Diagnostic: 13.50 Attempting to load new ViewModel from Intent with Extras
[0:] mvx:Diagnostic: 13.50 Attempting to load new ViewModel from Intent with Extras
06-12 11:45:01.868 I/dalvikvm( 3984): threadid=3: reacting to signal 3
06-12 11:45:01.948 I/dalvikvm( 3984): Wrote stack traces to '/data/anr/traces.txt'
Resolved pending breakpoint at 'c:\Source\Synchramed\SynchramedViewer\SynchramedViewer.Core\ViewModels\OverviewViewModel.cs:12,1' to void SynchramedViewer.Core.ViewModels.OverviewViewModel..ctor (SynchramedViewer.Core.IOverviewService overviewService) [0x00008].
Resolved pending breakpoint at 'c:\Source\Synchramed\SynchramedViewer\SynchramedViewer.Core\ViewModels\OverviewViewModel.cs:11,1' to void SynchramedViewer.Core.ViewModels.OverviewViewModel..ctor (SynchramedViewer.Core.IOverviewService overviewService) [0x00007].
06-12 11:45:02.358 I/dalvikvm( 3984): threadid=3: reacting to signal 3
06-12 11:45:02.397 I/dalvikvm( 3984): Wrote stack traces to '/data/anr/traces.txt'
06-12 11:45:02.858 I/dalvikvm( 3984): threadid=3: reacting to signal 3
06-12 11:45:02.898 I/dalvikvm( 3984): Wrote stack traces to '/data/anr/traces.txt'
06-12 11:45:03.367 I/dalvikvm( 3984): threadid=3: reacting to signal 3
06-12 11:45:03.407 I/dalvikvm( 3984): Wrote stack traces to '/data/anr/traces.txt'
06-12 11:45:03.868 I/dalvikvm( 3984): threadid=3: reacting to signal 3
06-12 11:45:03.898 I/dalvikvm( 3984): Wrote stack traces to '/data/anr/traces.txt'
06-12 11:45:04.377 I/dalvikvm( 3984): threadid=3: reacting to signal 3
06-12 11:45:04.407 I/dalvikvm( 3984): Wrote stack traces to '/data/anr/traces.txt'
06-12 11:45:04.888 I/dalvikvm( 3984): threadid=3: reacting to signal 3
06-12 11:45:04.918 I/dalvikvm( 3984): Wrote stack traces to '/data/anr/traces.txt'
06-12 11:45:05.388 I/dalvikvm( 3984): threadid=3: reacting to signal 3
06-12 11:45:05.417 I/dalvikvm( 3984): Wrote stack traces to '/data/anr/traces.txt'
06-12 11:45:05.898 I/dalvikvm( 3984): threadid=3: reacting to signal 3
06-12 11:45:05.918 I/dalvikvm( 3984): Wrote stack traces to '/data/anr/traces.txt'
06-12 11:45:06.398 I/dalvikvm( 3984): threadid=3: reacting to signal 3
06-12 11:45:06.498 I/dalvikvm( 3984): Wrote stack traces to '/data/anr/traces.txt'
06-12 11:45:06.897 I/dalvikvm( 3984): threadid=3: reacting to signal 3
06-12 11:45:06.927 I/dalvikvm( 3984): Wrote stack traces to '/data/anr/traces.txt'
06-12 11:45:07.408 I/dalvikvm( 3984): threadid=3: reacting to signal 3
06-12 11:45:07.437 I/dalvikvm( 3984): Wrote stack traces to '/data/anr/traces.txt'
06-12 11:45:07.918 I/dalvikvm( 3984): threadid=3: reacting to signal 3
06-12 11:45:07.947 I/dalvikvm( 3984): Wrote stack traces to '/data/anr/traces.txt'
06-12 11:45:08.428 I/dalvikvm( 3984): threadid=3: reacting to signal 3
06-12 11:45:08.448 I/dalvikvm( 3984): Wrote stack traces to '/data/anr/traces.txt'
06-12 11:45:08.937 I/dalvikvm( 3984): threadid=3: reacting to signal 3
06-12 11:45:08.977 I/dalvikvm( 3984): Wrote stack traces to '/data/anr/traces.txt'
[0:]
mvx:Warning: 21.37 using Inflate with a null parent viewGroup is discouraged - see https://github.com/MvvmCross/MvvmCross/issues/507
06-12 11:45:09.408 I/mono-stdout( 3984): mvx:Warning: 21.37 using Inflate with a null parent viewGroup is discouraged - see https://github.com/MvvmCross/MvvmCross/issues/507
[0:] mvx:Warning: 21.37 using Inflate with a null parent viewGroup is discouraged - see https://github.com/MvvmCross/MvvmCross/issues/507
06-12 11:45:09.438 I/dalvikvm( 3984): threadid=3: reacting to signal 3
06-12 11:45:09.498 I/dalvikvm( 3984): Wrote stack traces to '/data/anr/traces.txt'
06-12 11:45:09.947 I/dalvikvm( 3984): threadid=3: reacting to signal 3
06-12 11:45:09.977 I/dalvikvm( 3984): Wrote stack traces to '/data/anr/traces.txt'
06-12 11:45:10.468 I/dalvikvm( 3984): threadid=3: reacting to signal 3
06-12 11:45:10.498 I/dalvikvm( 3984): Wrote stack traces to '/data/anr/traces.txt'
06-12 11:45:10.958 I/dalvikvm( 3984): threadid=3: reacting to signal 3
06-12 11:45:10.998 I/dalvikvm( 3984): Wrote stack traces to '/data/anr/traces.txt'
06-12 11:45:11.327 D/Mono ( 3984): Remapped public key token of retargetable assembly System from 7cec85d7bea7798e to b77a5c561934e089
06-12 11:45:11.327 D/Mono ( 3984): The request to load the retargetable assembly System v2.0.5.0 was remapped to System v2.0.0.0
06-12 11:45:11.347 D/Mono ( 3984): Unloading image System.dll [0xf67590].
06-12 11:45:11.347 D/Mono ( 3984): Image addref System[0xf615e0] -> System.dll[0x6dac70]: 10
06-12 11:45:11.357 D/Mono ( 3984): Assembly Ref addref Cirrious.CrossCore[0x1eb4b8] -> System[0x6ce4d0]: 9
06-12 11:45:11.918 D/dalvikvm( 3984): GREF has increased to 201
我在输出中看到这样的mvx:Warning:21.37不鼓励使用带有空父视图组的充气-请参阅
所以我访问了那个链接,但找不到任何有用的东西,然后我偶然发现了这个-
所以我所有的控件和布局都有布局宽度
当我在Day30变量上调试应用程序时,我的ViewModel构造函数似乎中断了
private readonly IOverviewService _overviewService;
public OverviewViewModel (IOverviewService overviewService)
{
TurnOver = 100.00;
Day30 = 20.00;
Day60 = 30.00;
Day90 = 90.00;
Day120 = 120.00;
Per30 = 1;
Per60 = 2;
Per90 = 3;
Per120 = 4;
Total = 400.00;
PerTotal = 200.00;
NoOfVisits = 3;
string a = "sdlfkj";
//this = overviewService.GetOverviewReport (this);
}
有人知道为什么会这样吗
我不认为这和MvvmCross有任何关系
编辑
因此,我想为这个问题添加更多细节
它似乎进入了ViewModel的构造函数,然后将中断。当我试图查看我的布局时,我看到营业额的值是=0,实际上它应该=100.00
我注释掉了ViewModel构造函数中的代码,它似乎做了与上面完全相同的事情,其中营业额的值为=0。请添加布局、视图和ViewModel忽略使用带有空父视图组的充气消息。您是否可以在问题中添加更多关于什么中断或失败的信息?我不清楚你的问题出了什么问题。当您从构造函数中删除所有代码时,是否仍会发生任何错误?如果您可以编辑问题以添加有关失败原因的更多详细信息,我们可以尝试提供帮助:我已经包含了布局和视图模型。我添加了有关构造函数的更多详细信息和其他详细信息
<?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:orientation="horizontal"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/linearLayout9">
<TextView
android:text="Ex Vat"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/tvExVat" />
<TextView
android:text="Turnover"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/tvTurnOver" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/linearLayout1">
<TextView
android:text="Today"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/tvTurnOverToday" />
<TextView
android:text="MTD"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/vTurnOverMtd" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/linearLayout2">
<TextView
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/vTurnOverTodayVal"
local:MvxBind="Text TurnOver" />
<TextView
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/vTurnOverMtdVal"
local:MvxBind="Text TurnOver" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/linearLayout10">
<TextView
android:text="Inc Vat"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/tvIncVat" />
<TextView
android:text="Cash Collected"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/tvCashCollected" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/linearLayout3">
<TextView
android:text="Today"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/tvCashCollectedToday" />
<TextView
android:text="MTD"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/tvCashCollectedMtd" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/linearLayout4">
<TextView
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/tvCashCollectedTodayVal" />
<TextView
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/tvCashCollectedMtdVal" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/linearLayout11">
<TextView
android:text="Net Collectable Book"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/tvCollectable" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/linearLayout5">
<TextView
android:text="30"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/tvCollectable30" />
<TextView
android:text="Small Text"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/tvCollectable30Val" />
<TextView
android:text="Small Text"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/tvCollectable30Per" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/linearLayout6">
<TextView
android:text="60"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/ttvCollectable60" />
<TextView
android:text="Small Text"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/ttvCollectable60Val" />
<TextView
android:text="Small Text"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/tvCollectable60Per" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/linearLayout7">
<TextView
android:text="90"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/tvCollectable90" />
<TextView
android:text="Small Text"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/tvCollectable90Val" />
<TextView
android:text="Small Text"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/tvCollectable90Per" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/linearLayout8">
<TextView
android:text="120"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/tvCollectable120" />
<TextView
android:text="Small Text"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/tvCollectable120Val" />
<TextView
android:text="Small Text"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/ttvCollectable120Per" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/linearLayout12" />
</LinearLayout>
using Cirrious.MvvmCross.ViewModels;
using System.Collections.Generic;
namespace SynchramedViewer.Core.ViewModels
{
public class OverviewViewModel
: MvxViewModel
{
private readonly IOverviewService _overviewService;
public OverviewViewModel (IOverviewService overviewService)
{
TurnOver = 100.00;
Day30 = 20.00;
Day60 = 30.00;
Day90 = 90.00;
Day120 = 120.00;
Per30 = 1;
Per60 = 2;
Per90 = 3;
Per120 = 4;
Total = 400.00;
PerTotal = 200.00;
NoOfVisits = 3;
string a = "sdlfkj";
//this = overviewService.GetOverviewReport (this);
}
//Billed by the doctors
private double _turnOver;
public double TurnOver
{
get { return _turnOver; }
set { _turnOver = value; RaisePropertyChanged(() => TurnOver); }
}
//Cash collected
private double _day30;
public double Day30
{
get { return _day30; }
set { _day30 = value; RaisePropertyChanged(() => Day30); }
}
private double _day60;
public double Day60
{
get { return _day60; }
set { _day60 = value; RaisePropertyChanged(() => Day60); }
}
private double _day90;
public double Day90
{
get { return _day90; }
set { _day90 = value; RaisePropertyChanged(() => Day90); }
}
private double _day120;
public double Day120
{
get { return _day120; }
set { _day120 = value; RaisePropertyChanged(() => Day120); }
}
private double _total;
public double Total
{
get { return _total; }
set { _total = value; RaisePropertyChanged(() => Total); }
}
//Cash collected shown as a percentage
private double _per30;
public double Per30
{
get { return _per30; }
set { _per30 = value; RaisePropertyChanged(() => Per30); }
}
private double _per60;
public double Per60
{
get { return _per60; }
set { _per60 = value; RaisePropertyChanged(() => Per60); }
}
private double _per90;
public double Per90
{
get { return _per90; }
set { _per90 = value; RaisePropertyChanged(() => Per90); }
}
private double _per120;
public double Per120
{
get { return _per120; }
set { _per120 = value; RaisePropertyChanged(() => Per120); }
}
private double _perTotal;
public double PerTotal
{
get { return _perTotal; }
set { _perTotal = value; RaisePropertyChanged(() => PerTotal); }
}
//Number of patients visited
private double _noOfVisits;
public double NoOfVisits
{
get { return _noOfVisits; }
set { _noOfVisits = value; RaisePropertyChanged(() => NoOfVisits); }
}
public OverviewViewModel GetData()
{
return _overviewService.GetOverviewReport ();
}
}
}