第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

是否有關(guān)于使用 .Net Standard 的 MvvmCross.Forms 和本地化的教程

是否有關(guān)于使用 .Net Standard 的 MvvmCross.Forms 和本地化的教程

C#
慕運(yùn)維8079593 2022-12-24 14:49:19
我正在嘗試學(xué)習(xí)如何使用 MvvmCross.Forms 在 Xamarin Forms 應(yīng)用程序中實(shí)施和測(cè)試本地化。使用 Visual Studio 2017 或 2019 社區(qū)版。到目前為止,我已嘗試按照教程進(jìn)行操作。https://www.mvvmcross.com/documentation/plugins/resxlocalizationhttps://mobileprogrammerblog.wordpress.com/2017/12/30/mvvm-cross-with-xamarin-platform-resx-localization/https://learn.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/localization/但是這些都沒(méi)有顯示如何為 .Net Standard 類實(shí)現(xiàn)解決方案,其中 Visual Studio 解決方案具有以下設(shè)置。Application.Core - 這用于 ViewModels 和服務(wù)(帶有 MvvmCross NuGet 的 .Net Standard 2.0 庫(kù))Application.UI - 這是共享的視圖和視圖邏輯(.Net Standard 2.0 Library with Xamarin.Forms MvvmCross MvvmCross.Forms NuGets)Application.UWP - 特定于應(yīng)用程序的演示者 (Xamarin.Forms MvvmCross MvvmCross.Forms NuGets)Application.Android - 特定于應(yīng)用程序的演示者 (Xamarin.Forms MvvmCross MvvmCross.Forms NuGets)Application.iOS - 特定于應(yīng)用程序的演示者(Xamarin.Forms MvvmCross MvvmCross.Forms NuGets)NuGet 版本Xamarin.Forms-v3.6MvvmCross-v6.2.3MvvmCross.Forms-v6.2.3我想了解如何使用盡可能少的代碼進(jìn)入特定于應(yīng)用程序的表示層來(lái)實(shí)現(xiàn)本地化。任何人都可以指出有關(guān)如何使用 Xamarin.Forms 實(shí)現(xiàn) MvvmCross.Forms 的教程嗎?我很高興使用 JSon、RESX 或任何其他方法來(lái)存儲(chǔ)特定語(yǔ)言,但我也希望能夠支持從右到左的語(yǔ)言和布局。
查看完整描述

1 回答

?
萬(wàn)千封印

TA貢獻(xiàn)1891條經(jīng)驗(yàn) 獲得超3個(gè)贊

如果您使用的是 Xamarin Forms,則可以在您的核心項(xiàng)目中創(chuàng)建 resx 文件,例如 AppResources.resx 和 AppResources.es.resx 并在其中放置一個(gè)簡(jiǎn)單的文本,例如:


在 AppResources.resx


<data name="Hello" xml:space="preserve">

    <value>Hello</value> 

</data>

并在 AppResources.es.resx


<data name="Hello" xml:space="preserve">

    <value>Hola</value> 

</data>

然后創(chuàng)建一個(gè)類,名稱類似于從 MvxViewModel 擴(kuò)展的 BaseViewModel,并在其中引用本地化字符串的索引:


public class BaseViewModel : MvxViewModel

{

    public BaseViewModel()

    {

    }


    public string this[string index] => AppResources.ResourceManager.GetString(index);

}

現(xiàn)在從該 BaseViewModel 擴(kuò)展所有視圖模型。然后在來(lái)自 xamarin 表單的 xaml 文件中,當(dāng)您創(chuàng)建一個(gè)內(nèi)容頁(yè)面時(shí),將其設(shè)為 MvxContentPage 并且您可以通過(guò)它附加一個(gè)視圖模型x:TypeArguments,那里有對(duì) AppResources 索引的引用,所以如果想使用來(lái)自本地化 resx 的字符串,只需使用常規(guī)的 xamarin 表單綁定并將字符串名稱作為索引傳遞,例如:


<Label

    FontSize="Medium"

    TextColor="Black"

    Text="{Binding [Hello]}" />

或者使用 mvx 綁定系統(tǒng)


<Label

    FontSize="Medium"

    TextColor="Black"

    mvx:Bi.nd="Text [Hello]" />

您可以檢查Star Wars Sample 項(xiàng)目以查看有多少東西(如本地化字符串)有效;)


查看完整回答
反對(duì) 回復(fù) 2022-12-24
  • 1 回答
  • 0 關(guān)注
  • 94 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)