Localization 本地:当资源文本是Xamarin应用程序中MvxListView的itemtemplate的一部分时,MvxLang无法将其绑定到TextView

Localization 本地:当资源文本是Xamarin应用程序中MvxListView的itemtemplate的一部分时,MvxLang无法将其绑定到TextView,localization,xamarin.android,mvvmcross,Localization,Xamarin.android,Mvvmcross,问题:-本地:使用MVVMCross中的本地化功能,当资源文本是Xamarin应用程序中MvxListView的itemtemplate的一部分时,MvxLang无法将其绑定到TextView 我的应用程序是Xamarin.android,使用MVVMCross,在resx文件中使用了MVVMCross的本地化功能。 可在此处找到运行示例: 我使用viewmodel(AllBillsViewModel)BillClickedCommand中的以下语法通过代码获得本地化字符串:- _dialogS

问题:-本地:使用MVVMCross中的本地化功能,当资源文本是Xamarin应用程序中MvxListView的itemtemplate的一部分时,MvxLang无法将其绑定到TextView

我的应用程序是Xamarin.android,使用MVVMCross,在resx文件中使用了MVVMCross的本地化功能。 可在此处找到运行示例:

我使用viewmodel(AllBillsViewModel)BillClickedCommand中的以下语法通过代码获得本地化字符串:-

_dialogService.ShowAlertAsync( string.Format(TextSource.GetText("InformationReceivedMessage"),  bill.CustomerEmail, bill.AmountPaid), TextSource.GetText("InformationReceivedHeader"), TextSource.GetText("InformationReceivedButtonText"));
还有我的主视图页面,其中local:mvxLang是按钮属性,它显示来自所选区域性资源的按钮文本,效果也很好

<Button ... local:MvxLang="Text ViewBillsResourceText" local:MvxBind="Click NavigateAllBills" />
在visual studio输出窗口中获取警告,如下所示:

[0:] MvxBind:Warning:  9.78 Unable to bind: source property source not found Property:TextSource on Bill
02-10 07:41:52.020 I/MvxBind ( 4357):   9.78 Unable to bind: source property source not found Property:TextSource on Bill
我在MVVMCross正式网站上找不到足够的帮助,在同一网站上也找不到太多的讨论点。当从pluralsight培训中引用时,在下载的“My Trains”示例中也存在同样的问题


请帮忙。

我的问题解决了。参考链接:

这个链接问题有点类似。我用下面的方法解决了这个问题

无论我在viewModel中添加了什么TextSource属性,我都需要将其放入Bill.cs类中,该类是model

public IMvxLanguageBinder TextSource
    {
        get {
            //Mvx.Trace("****************TextSource get in bill.cs**************************");
            return new MvxLanguageBinder("", GetType().Name);
        }
    }
然后,资源文本键如下所示:-

<TextView android:layout_alignParentBottom="true"
android:layout_marginLeft="50dp"
android:layout_marginRight="16dp"
android:layout_width="90dp"
android:layout_height="wrap_content"
local:MvxLang="Text CustomerEmailTextView" />
<Mvx.MvxListView
android:layout_width="fill_parent"
android:layout_height="fill_parent"      
local:MvxBind="ItemsSource AllBills; ItemClick BillClickedCommand"
local:MvxItemTemplate="@layout/listitem_bill" />
Bill.CustomerEmailTextView
这是一种解决方法,实际上BaseViewModel具有TextSource属性,但在项模板的情况下它并不有用


请告诉我您是否有更好的解决方案,因为我们混合了viewmodel和model属性。

如果您想使用没有前缀的资源键,如Bill.xxxx,只需创建IMvxTextBinder,而不使用类型参数:
public IMvxLanguageBinder TextSource=>new MVXLLanguageBinder()然后,您可以忘记隐藏的命名约定,将TextSource放在BaseViewModel中
public IMvxLanguageBinder TextSource
    {
        get {
            //Mvx.Trace("****************TextSource get in bill.cs**************************");
            return new MvxLanguageBinder("", GetType().Name);
        }
    }
Bill.CustomerEmailTextView