[英]Which xaml-element i can bind to the property, if desired result - start the property at startup?
Let us have this property:让我们有这个属性:
public TCommand Read
{
get
{
return new TCommand
(
(obj) =>
{
}
);
}
}
How to launch this on start the program without deviating from the MVVM pattern?如何在不偏离 MVVM 模式的情况下在启动程序时启动它?
PS Sorry for my english PS对不起我的英语
You can refer to answer and do something like您可以参考答案并执行类似的操作
<Window x:Class="YourApplication.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="MainWindow"
mc:Ignorable="d"
xmlns:local="clr-namespace:YourApplication"
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
Height="450" Width="800">
<Window.DataContext>
<local:MainViewModel />
</Window.DataContext>
<i:Interaction.Triggers>
<i:EventTrigger EventName="Loaded">
<i:InvokeCommandAction Command="{Binding Read}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Window>
If you have a multiple windows in your application, you can hook into Application.Startup
event.如果您的应用程序中有多个 windows,则可以挂钩
Application.Startup
事件。 Let me know and I'll update my answer.让我知道,我会更新我的答案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.