Compare commits
7 Commits
23e90a5349
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
d980ce6ede
|
|||
|
e25d4639de
|
|||
|
416cbc9224
|
|||
|
4d858e69b8
|
|||
|
623359852b
|
|||
|
2f18db0de4
|
|||
|
f396aabaa2
|
1
.gitignore
vendored
1
.gitignore
vendored
@@ -4,3 +4,4 @@ obj/
|
|||||||
riderModule.iml
|
riderModule.iml
|
||||||
/_ReSharper.Caches/
|
/_ReSharper.Caches/
|
||||||
.idea/
|
.idea/
|
||||||
|
*.sln.DotSettings.user
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JackCraft.I18N", "JackCraft.I18N\JackCraft.I18N.csproj", "{C759B9D3-5362-4F9A-AE9F-FCB8B2E51B9A}"
|
|
||||||
EndProject
|
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Folder", "Solution Folder", "{AEC78522-0B34-4DF2-8373-DDED5BEE6ACB}"
|
|
||||||
ProjectSection(SolutionItems) = preProject
|
|
||||||
LICENSE = LICENSE
|
|
||||||
Readme.MD = Readme.MD
|
|
||||||
EndProjectSection
|
|
||||||
EndProject
|
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "Test\Test.csproj", "{933A9C2F-8C23-4898-A266-780A841218DD}"
|
|
||||||
EndProject
|
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestMvvm", "TestMvvm\TestMvvm.csproj", "{2558A760-25A2-4EA1-8F7B-960C54E1D898}"
|
|
||||||
EndProject
|
|
||||||
Global
|
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
|
||||||
Debug|Any CPU = Debug|Any CPU
|
|
||||||
Release|Any CPU = Release|Any CPU
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
|
||||||
{C759B9D3-5362-4F9A-AE9F-FCB8B2E51B9A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{C759B9D3-5362-4F9A-AE9F-FCB8B2E51B9A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{C759B9D3-5362-4F9A-AE9F-FCB8B2E51B9A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{C759B9D3-5362-4F9A-AE9F-FCB8B2E51B9A}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{933A9C2F-8C23-4898-A266-780A841218DD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{933A9C2F-8C23-4898-A266-780A841218DD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{933A9C2F-8C23-4898-A266-780A841218DD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{933A9C2F-8C23-4898-A266-780A841218DD}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{2558A760-25A2-4EA1-8F7B-960C54E1D898}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{2558A760-25A2-4EA1-8F7B-960C54E1D898}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{2558A760-25A2-4EA1-8F7B-960C54E1D898}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{2558A760-25A2-4EA1-8F7B-960C54E1D898}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
EndGlobalSection
|
|
||||||
EndGlobal
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
|
||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AEffectiveValue_00601_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FLibrary_003FApplication_0020Support_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003F5a525a9d918b377baff5efc711876365dd6b28a67a526bca563509277c197_003FEffectiveValue_00601_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
|
||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AIValueConverter_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FLibrary_003FApplication_0020Support_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F0d5de909919040338555601dd29873191e2000_003F6e_003F156c671e_003FIValueConverter_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
|
||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AManifestBasedResourceGroveler_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FLibrary_003FApplication_0020Support_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003Faa4010d4409494a18f9356117451768ad29a90b7ff96ac80dd7d963d6b383_003FManifestBasedResourceGroveler_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
|
||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AMultiBinding_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FLibrary_003FApplication_0020Support_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F5cfc269cf6784f4a9dec8ed13ac9f75de600_003F49_003F860db364_003FMultiBinding_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
|
||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ATest_002EMainWindow_002Eg_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FLibrary_003FApplication_0020Support_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003F1beb137ab36b71a8961f85c524c65a73ff2463ed_003FTest_002EMainWindow_002Eg_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
|
||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AThrowHelper_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FLibrary_003FApplication_0020Support_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F6d2342c247c64eb7a9b3702e481e4443f83e00_003Fc7_003F71d96ba5_003FThrowHelper_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
|
||||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AThrowHelper_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003FLibrary_003FApplication_0020Support_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003F4743f513c7ddc8411223a46f0ca426ed929391acebcff993721dff2f0c6b34_003FThrowHelper_002Ecs_002Fz_003A2_002D1/@EntryIndexedValue">ForceIncluded</s:String>
|
|
||||||
<s:Boolean x:Key="/Default/ResxEditorPersonal/CheckedGroups/=TestMvvm_002FAssets_002FResources/@EntryIndexedValue">True</s:Boolean>
|
|
||||||
<s:Boolean x:Key="/Default/ResxEditorPersonal/CheckedGroups/=Test_002FAssets_002FResources/@EntryIndexedValue">False</s:Boolean>
|
|
||||||
<s:Boolean x:Key="/Default/ResxEditorPersonal/Initialized/@EntryValue">True</s:Boolean></wpf:ResourceDictionary>
|
|
||||||
9
JackCraft.I18N.slnx
Normal file
9
JackCraft.I18N.slnx
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<Solution>
|
||||||
|
<Folder Name="/Solution Folder/">
|
||||||
|
<File Path="LICENSE"/>
|
||||||
|
<File Path="Readme.MD"/>
|
||||||
|
</Folder>
|
||||||
|
<Project Path="JackCraft.I18N/JackCraft.I18N.csproj"/>
|
||||||
|
<Project Path="Test/Test.csproj"/>
|
||||||
|
<Project Path="TestMvvm/TestMvvm.csproj"/>
|
||||||
|
</Solution>
|
||||||
@@ -9,7 +9,7 @@ internal class I18NBinding : MultiBinding
|
|||||||
public readonly IValueConverter KeyConverter;
|
public readonly IValueConverter KeyConverter;
|
||||||
public readonly IValueConverter ValueConverter;
|
public readonly IValueConverter ValueConverter;
|
||||||
|
|
||||||
public I18NBinding(string key, params dynamic[] values)
|
public I18NBinding(object key, params dynamic[] values)
|
||||||
{
|
{
|
||||||
Mode = BindingMode.OneWay;
|
Mode = BindingMode.OneWay;
|
||||||
TargetNullValue = key;
|
TargetNullValue = key;
|
||||||
@@ -18,8 +18,26 @@ internal class I18NBinding : MultiBinding
|
|||||||
KeyConverter = new I18NKeyConverter();
|
KeyConverter = new I18NKeyConverter();
|
||||||
ValueConverter = new I18NValueConverter();
|
ValueConverter = new I18NValueConverter();
|
||||||
Bindings.Add(new Binding { Source = I18NConfig.Manager, Path = nameof(I18NConfig.Manager.Culture) });
|
Bindings.Add(new Binding { Source = I18NConfig.Manager, Path = nameof(I18NConfig.Manager.Culture) });
|
||||||
|
|
||||||
|
switch (key)
|
||||||
|
{
|
||||||
|
// 处理 key 参数,可能是字符串或 BindingBase
|
||||||
|
case string keyStr:
|
||||||
|
Bindings.Add(new Binding { Source = keyStr });
|
||||||
|
break;
|
||||||
|
case BindingBase binding:
|
||||||
|
Bindings.Add(binding);
|
||||||
|
break;
|
||||||
|
// 其他情况,作为普通对象处理
|
||||||
|
default:
|
||||||
Bindings.Add(new Binding { Source = key });
|
Bindings.Add(new Binding { Source = key });
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var value in values)
|
foreach (var value in values)
|
||||||
Bindings.Add(value);
|
if (value is BindingBase valueBinding)
|
||||||
|
Bindings.Add(valueBinding);
|
||||||
|
else
|
||||||
|
Bindings.Add(new Binding { Source = value });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,19 @@
|
|||||||
|
using Avalonia.Data;
|
||||||
using Avalonia.Markup.Xaml;
|
using Avalonia.Markup.Xaml;
|
||||||
|
|
||||||
namespace JackCraft.I18N;
|
namespace JackCraft.I18N;
|
||||||
|
|
||||||
public class I18NExtension(string key, params dynamic[] values) : MarkupExtension
|
public class I18NExtension : MarkupExtension
|
||||||
{
|
{
|
||||||
|
private readonly object _key;
|
||||||
|
private readonly dynamic[] _values;
|
||||||
|
|
||||||
|
public I18NExtension(string key, params dynamic[] values)
|
||||||
|
{
|
||||||
|
_key = key;
|
||||||
|
_values = values;
|
||||||
|
}
|
||||||
|
|
||||||
public I18NExtension(string key) : this(key, [])
|
public I18NExtension(string key) : this(key, [])
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -31,8 +41,43 @@ public class I18NExtension(string key, params dynamic[] values) : MarkupExtensio
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 支持 BindingBase 作为 key
|
||||||
|
public I18NExtension(BindingBase key, params dynamic[] values)
|
||||||
|
{
|
||||||
|
_key = key;
|
||||||
|
_values = values;
|
||||||
|
}
|
||||||
|
|
||||||
|
public I18NExtension(BindingBase key) : this(key, [])
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public I18NExtension(BindingBase key, dynamic value1) : this(key, [value1])
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public I18NExtension(BindingBase key, dynamic value1, dynamic value2) : this(key, [value1, value2])
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public I18NExtension(BindingBase key, dynamic value1, dynamic value2, dynamic value3) : this(key,
|
||||||
|
[value1, value2, value3])
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public I18NExtension(BindingBase key, dynamic value1, dynamic value2, dynamic value3, dynamic value4) : this(key,
|
||||||
|
[value1, value2, value3, value4])
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public I18NExtension(BindingBase key, dynamic value1, dynamic value2, dynamic value3, dynamic value4,
|
||||||
|
dynamic value5) :
|
||||||
|
this(key, [value1, value2, value3, value4, value5])
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public override object ProvideValue(IServiceProvider serviceProvider)
|
public override object ProvideValue(IServiceProvider serviceProvider)
|
||||||
{
|
{
|
||||||
return new I18NBinding(key, values);
|
return new I18NBinding(_key, _values);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net9.0</TargetFramework>
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
<LangVersion>latestmajor</LangVersion>
|
<LangVersion>latestmajor</LangVersion>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Avalonia" Version="11.2.3"/>
|
<PackageReference Include="Avalonia" Version="11.3.11"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
17
Readme.MD
17
Readme.MD
@@ -50,10 +50,21 @@ var value = I18NManager.Get<string>("Hello", CultureInfo.InvariantCulture, Usern
|
|||||||
<Window xmlns="https://github.com/avaloniaui"
|
<Window xmlns="https://github.com/avaloniaui"
|
||||||
xmlns:i18N="clr-namespace:JackCraft.I18N;assembly=JackCraft.I18N">
|
xmlns:i18N="clr-namespace:JackCraft.I18N;assembly=JackCraft.I18N">
|
||||||
<StackPanel>
|
<StackPanel>
|
||||||
|
<!-- Resources:
|
||||||
|
资源名称 | 默认值 | 中文
|
||||||
|
Test | Test | 测试
|
||||||
|
Hello | Hello, {0} | 你好, {0}
|
||||||
|
-->
|
||||||
|
<!-- ViewModel:
|
||||||
|
public string UserText { get; set; } = "UserName";
|
||||||
|
public string TestKey { get; set; } = "Test";
|
||||||
|
public string HelloKey { get; set; } = "Hello";
|
||||||
|
-->
|
||||||
<TextBlock Text="{i18N:I18N Test}" /> <!-- 输出: 测试 -->
|
<TextBlock Text="{i18N:I18N Test}" /> <!-- 输出: 测试 -->
|
||||||
<TextBlock Text="{i18N:I18N Hello, User}" /> <!-- 输出: 你好, User -->
|
<TextBlock Text="{i18N:I18N Hello, UserName}" /> <!-- 输出: 你好, UserName -->
|
||||||
<!-- ViewModel: public string User { get; set; } = "User"; -->
|
<TextBlock Text="{i18N:I18N Hello, {Binding UserText}}" /> <!-- 输出: 你好, UserName -->
|
||||||
<TextBlock Text="{i18N:I18N Hello, {Binding User}}" /> <!-- 输出: 你好, User -->
|
<TextBlock Text="{i18N:I18N {Binding Test}}" /> <!-- 输出: 测试 -->
|
||||||
|
<TextBlock Text="{i18N:I18N {Binding HelloKey}, {Binding HelloKey}}" /> <!-- 输出: 你好, Hello -->
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Window>
|
</Window>
|
||||||
```
|
```
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<TargetFramework>net9.0</TargetFramework>
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
|
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
|
||||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||||
@@ -9,12 +9,12 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Avalonia" Version="11.2.3"/>
|
<PackageReference Include="Avalonia" Version="11.3.11"/>
|
||||||
<PackageReference Include="Avalonia.Desktop" Version="11.2.3"/>
|
<PackageReference Include="Avalonia.Desktop" Version="11.3.11"/>
|
||||||
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.2.3"/>
|
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.3.11"/>
|
||||||
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.2.3"/>
|
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.3.11"/>
|
||||||
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
|
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
|
||||||
<PackageReference Include="Avalonia.Diagnostics" Version="11.2.3">
|
<PackageReference Include="Avalonia.Diagnostics" Version="11.3.11">
|
||||||
<IncludeAssets Condition="'$(Configuration)' != 'Debug'">None</IncludeAssets>
|
<IncludeAssets Condition="'$(Configuration)' != 'Debug'">None</IncludeAssets>
|
||||||
<PrivateAssets Condition="'$(Configuration)' != 'Debug'">All</PrivateAssets>
|
<PrivateAssets Condition="'$(Configuration)' != 'Debug'">All</PrivateAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
<root>
|
<root>
|
||||||
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" id="root"
|
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
|
||||||
|
id="root"
|
||||||
xmlns="">
|
xmlns="">
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
|
||||||
@@ -26,4 +27,7 @@
|
|||||||
<data name="Test1" xml:space="preserve">
|
<data name="Test1" xml:space="preserve">
|
||||||
<value>Test1: {0}</value>
|
<value>Test1: {0}</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="Test2" xml:space="preserve">
|
||||||
|
<value>Test2Test2</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
@@ -18,4 +18,7 @@
|
|||||||
<data name="Test1" xml:space="preserve">
|
<data name="Test1" xml:space="preserve">
|
||||||
<value>测试1: {0}</value>
|
<value>测试1: {0}</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="Test2" xml:space="preserve">
|
||||||
|
<value>测试2测试2</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<TargetFramework>net9.0</TargetFramework>
|
<TargetFramework>net10.0</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
|
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
|
||||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||||
@@ -14,16 +14,16 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Avalonia" Version="11.2.3"/>
|
<PackageReference Include="Avalonia" Version="11.3.11"/>
|
||||||
<PackageReference Include="Avalonia.Desktop" Version="11.2.3"/>
|
<PackageReference Include="Avalonia.Desktop" Version="11.3.11"/>
|
||||||
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.2.3"/>
|
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.3.11"/>
|
||||||
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.2.3"/>
|
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.3.11"/>
|
||||||
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
|
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
|
||||||
<PackageReference Include="Avalonia.Diagnostics" Version="11.2.3">
|
<PackageReference Include="Avalonia.Diagnostics" Version="11.3.11">
|
||||||
<IncludeAssets Condition="'$(Configuration)' != 'Debug'">None</IncludeAssets>
|
<IncludeAssets Condition="'$(Configuration)' != 'Debug'">None</IncludeAssets>
|
||||||
<PrivateAssets Condition="'$(Configuration)' != 'Debug'">All</PrivateAssets>
|
<PrivateAssets Condition="'$(Configuration)' != 'Debug'">All</PrivateAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.1"/>
|
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ namespace TestMvvm.ViewModels;
|
|||||||
|
|
||||||
public partial class MainWindowViewModel : ViewModelBase
|
public partial class MainWindowViewModel : ViewModelBase
|
||||||
{
|
{
|
||||||
[ObservableProperty] public string? test = Path.GetRandomFileName();
|
[ObservableProperty] private string? _test = Path.GetRandomFileName();
|
||||||
|
[ObservableProperty] private string _test2 = "Test2";
|
||||||
|
|
||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
public void RandomText()
|
public void RandomText()
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
<StackPanel>
|
<StackPanel>
|
||||||
<TextBlock Text="{Binding Test}" HorizontalAlignment="Center" VerticalAlignment="Center" />
|
<TextBlock Text="{Binding Test}" HorizontalAlignment="Center" VerticalAlignment="Center" />
|
||||||
<TextBlock Text="{i18N:I18N Test1, {Binding Test}}" HorizontalAlignment="Center" VerticalAlignment="Center" />
|
<TextBlock Text="{i18N:I18N Test1, {Binding Test}}" HorizontalAlignment="Center" VerticalAlignment="Center" />
|
||||||
|
<TextBlock Text="{i18N:I18N {Binding Test2}}" HorizontalAlignment="Center" VerticalAlignment="Center" />
|
||||||
<Button Content="随机文本"
|
<Button Content="随机文本"
|
||||||
Command="{Binding RandomTextCommand}" />
|
Command="{Binding RandomTextCommand}" />
|
||||||
<Button Content="切换中文"
|
<Button Content="切换中文"
|
||||||
|
|||||||
Reference in New Issue
Block a user