替代 x:Bind 在 UNO 平台中为 UWP 而不是 WASM、Droid 等工作
Replacement for x:Bind Working for UWP in UNO Platform but not WASM, Droid, etc
我目前正在使用 Prism 试用 Uno Platform,看看是否值得将我的一个项目从 WPF 迁移到 UWP 和 Uno。我已经使用 Prism 模板构建了这个应用程序。
我目前 运行 遇到一个问题,我通常通过调用存储在 class 静态区域名称中的静态区域名称来将区域分配给 ContentControl。
我的 WPF XAML 代码,来自 Shell.xaml:
<ContentControl Grid.Row="0"
VerticalAlignment="Bottom"
HorizontalAlignment="Stretch"
Margin="0,0,0,11"
prismRegions:RegionManager.RegionName="{x:Static blankCore:RegionNames.ContentHeaderRegion}"/>
但是,这不起作用,因为 UWP 中不存在 x:Static(XML 命名空间中的未知类型 'Static')。因此,在查看了有关 UWP 的一些文档之后,我使用了 x:Bind,现在代码如下所示:
<ContentControl Grid.Row="0"
VerticalAlignment="Bottom"
HorizontalAlignment="Stretch"
Margin="0,0,0,11"
prismRegions:RegionManager.RegionName="{x:Bind blankCore:RegionNames.ContentHeaderRegion}"/>
这是为 UWP 编译和 运行ning,但在切换到 WASM 或 Android 后,我在生成的文件中遇到各种错误:
c32.SetBinding(global::Prism.Regions.RegionManager.RegionNameProperty, new Windows.UI.Xaml.Data.Binding{ Mode = BindingMode.OneTime }.Apply(___b => /*defaultBindModeOneTime*/ global::Uno.UI.Xaml.BindingHelper.SetBindingXBindProvider(___b, this, ___ctx => ___ctx is global::BlankApp1.Shared.Views.Shell ___tctx ? (object)(___tctx.global::BlankApp1.Core.RegionNames.AuthenticateRegion) : null, null )));
错误如下:
我目前的RegionNames静态class如下:
namespace BlankApp1.Core
{
public class RegionNames
{
public static string ContentHeaderRegion = "ContentHeaderRegion";
/// ...
}
}
使用 'x:Bind' 是否是解决此问题的正确方法?是否有解决方法?
还是我应该做点别的?
已通过将 Uno.UI 库更新为 3.5.x 或更高版本解决此问题。我在 3.0.x
我目前正在使用 Prism 试用 Uno Platform,看看是否值得将我的一个项目从 WPF 迁移到 UWP 和 Uno。我已经使用 Prism 模板构建了这个应用程序。
我目前 运行 遇到一个问题,我通常通过调用存储在 class 静态区域名称中的静态区域名称来将区域分配给 ContentControl。
我的 WPF XAML 代码,来自 Shell.xaml:
<ContentControl Grid.Row="0"
VerticalAlignment="Bottom"
HorizontalAlignment="Stretch"
Margin="0,0,0,11"
prismRegions:RegionManager.RegionName="{x:Static blankCore:RegionNames.ContentHeaderRegion}"/>
但是,这不起作用,因为 UWP 中不存在 x:Static(XML 命名空间中的未知类型 'Static')。因此,在查看了有关 UWP 的一些文档之后,我使用了 x:Bind,现在代码如下所示:
<ContentControl Grid.Row="0"
VerticalAlignment="Bottom"
HorizontalAlignment="Stretch"
Margin="0,0,0,11"
prismRegions:RegionManager.RegionName="{x:Bind blankCore:RegionNames.ContentHeaderRegion}"/>
这是为 UWP 编译和 运行ning,但在切换到 WASM 或 Android 后,我在生成的文件中遇到各种错误:
c32.SetBinding(global::Prism.Regions.RegionManager.RegionNameProperty, new Windows.UI.Xaml.Data.Binding{ Mode = BindingMode.OneTime }.Apply(___b => /*defaultBindModeOneTime*/ global::Uno.UI.Xaml.BindingHelper.SetBindingXBindProvider(___b, this, ___ctx => ___ctx is global::BlankApp1.Shared.Views.Shell ___tctx ? (object)(___tctx.global::BlankApp1.Core.RegionNames.AuthenticateRegion) : null, null )));
错误如下:
我目前的RegionNames静态class如下:
namespace BlankApp1.Core
{
public class RegionNames
{
public static string ContentHeaderRegion = "ContentHeaderRegion";
/// ...
}
}
使用 'x:Bind' 是否是解决此问题的正确方法?是否有解决方法? 还是我应该做点别的?
已通过将 Uno.UI 库更新为 3.5.x 或更高版本解决此问题。我在 3.0.x