c# - 如何将命令绑定到表单的加载事件
问题描述
我正在尝试在加载主表单时运行一些代码。我在这里使用了代码。我使用 MVVM 模式将 wpf 与 .NET core 3.1 一起使用。当我尝试添加 nuget 包时System.Windows.Interactivity
出现错误This package may not be fully compatible with your project
。我假设问题是我正在使用的 .NET 版本。有没有办法使它适用于 .NET Core 3.1?
解决方案
System.Windows.Interactivity 已被 nuget 包替换。
而不是引用您添加包:
Microsoft.Xaml.Behaviors.Wpf
然后,您将需要一个 xmlns。
来自https://devblogs.microsoft.com/dotnet/open-sourcing-xaml-behaviors-for-wpf/ (更多信息参见 )。
迁移步骤如下:
删除对“Microsoft.Expression.Interactions”和“System.Windows.Interactivity”的引用安装“Microsoft.Xaml.Behaviors.Wpf”NuGet 包。XAML 文件 – 替换 xmlns 命名空间“<a href="http://schemas.microsoft.com/expression/2010/interactivity" rel="nofollow noreferrer">http://schemas.microsoft.com/expression/2010/交互性”和“<a href="http://schemas.microsoft.com/expression/2010/interactions" rel="nofollow noreferrer">http://schemas.microsoft.com/expression/2010/interactions“与“ <a href="http://schemas.microsoft.com/xaml/behaviors" rel="nofollow noreferrer">http://schemas.microsoft.com/xaml/behaviors“ C# 文件 – 替换 c# 文件中的使用” Microsoft.Xaml.Interactivity”和“Microsoft.Xaml.Interactions”与“Microsoft.Xaml.Behaviors”<
这是网络核心友好的。
它与 for like 不完全一样,我发现我的一段代码不兼容。不过,对于大多数人来说,这可能不是问题。
推荐阅读
- regex - Makefile 变量 - 替换变量中的空格
- mysql - 嵌套游标声明问题 Mysql
- javascript - 试图制作一个向用户发送 DM 的机器人
- python - boto3、aiobotocore、awscli、botocore的版本不兼容;无法解决
- c++ - 在c ++中,以相反顺序排序的最快方法是什么?
- rust - 将整数转换为浮点数时如何添加正确的类型注释?
- php - 无法调用 php artisan
- spring - Spring-boot应用程序部署问题
- unit-testing - 在 Rust 中比较函数是否相等
- amazon-web-services - 为什么我的 CodeDeploy 到 lambda 不起作用?