使用 Catel 登录表单

Login form with Catel

我正在继续使用 Catel 进行实验,并且想知道一些事情:

这是我的代码

 private   void OnMenuClickExecute(Telerik.Windows.RadRoutedEventArgs e)
    {
        var typeFactory = this.GetServiceLocator();
        var dependencyResolver = this.GetDependencyResolver();
        var uiVisualizerService = dependencyResolver.Resolve<IUIVisualizerService>();

        var login = typeFactory.ResolveType<LoginViewModel>();


        IViewLocator locator = dependencyResolver.Resolve<IViewLocator>();

        uiVisualizerService.ShowDialog(login);

风景

<catel:DataWindow x:Class="CatelDocking.Login.Views.LoginView"
               xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
               xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
               xmlns:catel="http://catel.codeplex.com"
               xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" SizeToContent="WidthAndHeight">

<catel:StackGrid>
    <catel:StackGrid.RowDefinitions>
        <RowDefinition Height="25" />
        <RowDefinition Height="25" />
        <RowDefinition Height="25" />
    </catel:StackGrid.RowDefinitions>
    <catel:StackGrid.ColumnDefinitions>
        <ColumnDefinition Width="120"/>
        <ColumnDefinition Width="120"  />
    </catel:StackGrid.ColumnDefinitions>

    <Label Content="Username"></Label>
    <Label Content="Password" Grid.Row="1"></Label>

    <TextBox Grid.Column="1" Text="{Binding Username,Mode=TwoWay}"></TextBox>
    <TextBox Grid.Column="1" Grid.Row="1" Text="{Binding Password,Mode=TwoWay}"></TextBox>
    <telerik:RadButton Grid.ColumnSpan="2" Grid.Row="2" HorizontalAlignment="Right" Content="Ok"></telerik:RadButton>
</catel:StackGrid>

谢谢

  1. 是的,使用自定义模式并在 window
  2. 的代码隐藏中使用 AddCustomButton 添加按钮
  3. 这是您作为开发人员可以发现的东西,对所有 fx/wpf 都一样,但像这样应该就足够了:

uiVisualizerService.ShowDialog<LoginViewModel>();