2016-12-13 25 views
0

私はプリズムを学んでいて、彼らの概念の一部は私にとっては明らかではないことを認めます。私はいくつかの問題を抱えており、それを解決する方法はわかりません。 私はいくつかのビューには、例えば、プロフィール、終わった後、クレジットカードで表示し、次に住所を表示してから何かを追加した構成のcreaotrを構築する必要があります。 そのうちのいくつかは、プロファイルとアドレスのように必要です。私たちがプロフィールを持っていないなら、私達は対処することができません。それらのうちのいくつかはクレジットカードのようなnesseceryではありません。プリズムを使用して1つのタブで順番にビューに移動

私の会社は、1つの一般的なTabControlと1つの共通のtabItemを使用してそれを行いたいと考えています。このtabItemの中で私はすべてのビューを表示する必要があります。 「次へ」または「ミス」ボタンを押した後にビューを変更する必要があります。また、私はPreviousStepを持っています。 いくつかのオーダーで多くのビューを保存する方法は私の質問。

は、これまでのところ: 私はクラス

GeneralBaseViewModel : BindableBase, INavigationAware 

を持っていることは、すべてのクラスのための共通である抽象クラスです。

私だけ

mvvm:RegionManager.RegionName="MainTabControlRegion" 

telerikとして持ってGeneralHost.xamlありますRadTabControl(ので、通常のTabControlを)。すべてのビューに共通のtabControlを持つクラスです。

私はMainTabControlRegionの内部

if (viewType == typeof(IConfiguration)) 
       { 
        this.RegionManager.RequestNavigate(RegionNames.MainRegion, typeof(GeneralHost).FullName); 
        this.RegionManager.RequestNavigate(RegionNames.MainTabControlRegion, viewType.FullName); 
        return; 
       } 

を追加しましたところ、私はNavigateOnを実施して最初のビューでこれらのタブを開いてくださいメニューで

私は、ビューを追加したい - >私は見てMyProfileViewModel(それはIConfigurationを実装)とマイプロファイルを作成以下のような:

<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
       xmlns:lang="clr-namespace:LanguageResources.Properties;assembly=LanguageResources" 
       xmlns:mvvm="http://prismlibrary.com/" 
       xmlns:mainRegionItems="clr-namespace:App.MainRegionItems" 
      xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" 
      xmlns:converters="clr-namespace:Shared.Converters;assembly=Shared" 
      xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" 
      xmlns:enumerators="clr-namespace:AppManager.Models.ComplexTypes.Enumerators;assembly=AppManager.Models" 
      Style="{DynamicResource ControlDefaultStyle}" 
     d:DataContext="{d:DesignInstance mainRegionItems:MyProfileViewModel, IsDesignTimeCreatable=True}" 
     x:Class="App.MainRegionItems.ConfigurationOfProfile" mc:Ignorable="d" mvvm:ViewModelLocator.AutoWireViewModel="True" d:DesignHeight="800" d:DesignWidth="800" > 
    <i:Interaction.Triggers> 
     <i:EventTrigger EventName="Loaded"> 
      <i:InvokeCommandAction Command="{Binding LoadDataCommand}"/> 
     </i:EventTrigger> 
    </i:Interaction.Triggers> 
    <telerik:RadBusyIndicator BusyContent="{x:Static lang:Resources.PleadeWait}" IsBusy="{Binding IsBusy}"> 
     <Grid Background="White" > 
      <Grid.ColumnDefinitions> 
       <ColumnDefinition Width="Auto"></ColumnDefinition> 
       <ColumnDefinition Width="*"></ColumnDefinition> 
      </Grid.ColumnDefinitions> 
      <Grid.RowDefinitions> 
       <RowDefinition Height="Auto"></RowDefinition> 
       <RowDefinition Height="*"></RowDefinition> 
      </Grid.RowDefinitions> 

      <GroupBox Grid.Column="0" Grid.Row="0" Header="{x:Static lang:Resources.AddressSender}" 
         HorizontalAlignment="Left" VerticalAlignment="Top" Height="307" Width="400"> 
       <Grid> 
        <Grid.Resources> 
         <Style TargetType="{x:Type TextBox}"> 
          <Setter Property="Margin" Value="5" /> 
         </Style> 
        </Grid.Resources> 
        <Grid.ColumnDefinitions> 
         <ColumnDefinition Width="Auto"></ColumnDefinition> 
         <ColumnDefinition Width="*"></ColumnDefinition> 
        </Grid.ColumnDefinitions> 
        <Grid.RowDefinitions> 
         <RowDefinition></RowDefinition> 
         <RowDefinition></RowDefinition> 
         <RowDefinition></RowDefinition> 
         <RowDefinition></RowDefinition> 
         <RowDefinition></RowDefinition> 
         <RowDefinition></RowDefinition> 
         <RowDefinition></RowDefinition> 
         <RowDefinition></RowDefinition> 
        </Grid.RowDefinitions> 
        <Label Grid.Row="0" Grid.Column="0" Content="{x:Static lang:Resources.Name}" /> 
        <TextBox Grid.Row="0" Grid.Column="1" Text="{Binding ModifiedInstance.DefaultSendingAddress.CompanyName,ValidatesOnDataErrors=True, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" /> 
        <Label Grid.Row="1" Grid.Column="0" 
            Content="{x:Static lang:Resources.AdditionalName}" /> 
        <TextBox Grid.Row="1" Grid.Column="1" 
            Text="{Binding ModifiedInstance.DefaultSendingAddress.AdditionalName,ValidatesOnDataErrors=True,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" /> 
       </Grid> 
      </GroupBox> 
      <Menu Grid.Column="1" Grid.Row="1" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="10" Height="23" > 
       <MenuItem Style="{DynamicResource MenuItemStyle}" Command="{Binding SaveDataCommand}" 
           Header="{x:Static lang:Resources.SaveData}"> 
        <MenuItem.Icon> 
         <Image Source="/App;component/Icons/Zapisz.ico" Height="25" /> 
        </MenuItem.Icon> 
       </MenuItem> 
       <MenuItem Style="{DynamicResource MenuItemStyle}" Command="{Binding NextStepCommand}" 
           Header="{x:Static lang:Resources.NextStep}"> 
        <MenuItem.Icon> 
         <Image Source="/App;component/Icons/Zapisz.ico" Height="25" /> 
        </MenuItem.Icon> 
       </MenuItem> 
       <MenuItem Style="{DynamicResource MenuItemStyle}" Command="{Binding PreviousStepCommand}" 
           Header="{x:Static lang:Resources.PreviousStep}"> 
        <MenuItem.Icon> 
         <Image Source="/App;component/Icons/Zapisz.ico" Height="25" /> 
        </MenuItem.Icon> 
       </MenuItem> 
      </Menu> 
     </Grid> 
    </telerik:RadBusyIndicator> 
</UserControl> 

マイVM:

public class ConfigurationOfProfileViewModel : GeneralBaseViewModel, IConfiguration 
    { 
     /// <summary> 
     /// The report title. 
     /// </summary> 
     protected override string GeneralDetailTitle => "Configuration"; 

     public override void OnNavigatedTo(NavigationContext navigationContext) 
     { 
      this.GetConfigurationData(); 
     } 

     /// <summary> 
     /// The get report data. 
     /// </summary> 
     public void GetConfigurationData() 
     { 
      this.LoadingOn(); 
      this.SetHeaderTitle(); 
      this.LoadData(); 
      this.LoadingOff(); 
     } 

     public int indexOrder = 0; 

     private ICommand saveDataCommand; 
     public ICommand SaveDataCommand => saveDataCommand ?? (saveDataCommand = new DelegateCommand(SaveData)); 

     private ICommand loadDataCommand; 
     public ICommand LoadDataCommand => loadDataCommand ?? (loadDataCommand = new DelegateCommand(LoadData)); 

     private ICommand nextStepCommand; 
     public ICommand NextStepCommand => nextStepCommand ?? (nextStepCommand = new DelegateCommand(NextStep)); 

     private ICommand previousStepCommand; 
     public ICommand PreviousStepCommand => previousStepCommand ?? (previousStepCommand = new DelegateCommand(LoadData)); 

     private Profile modifiedInstance; 
     public Profile ModifiedInstance 
     { 
      get 
      { 
       return this.modifiedInstance; 
      } 
      private set 
      { 
       this.SetProperty(ref this.modifiedInstance, value); 
       this.OnPropertyChanged(() => this.ModifiedInstance); 
      } 
     } 

     private void LoadData() 
     { 
      var repProfile = new ProfileRepository(); 
      Task<Profile> taskProfile = repProfile.GetPodmiot(); 
      this.ModifiedInstance = taskProfile.Result; 

      if (this.ModifiedInstance == null) 
      { 
       this.ModifiedInstance = new Profile(); 
      } 
      if (this.ModifiedInstance.ProfileData == null) 
      { 
       this.ModifiedInstance.ProfileData = new Address(); 
      } 
      this.OnPropertyChanged(() => this.ModifiedInstance); 
     } 

     public async void SaveData() 
     { 
      this.LoadingOn(); 

      try 
      { 
       var repProfile = new ProfileRepository(); 
       var taskProfiles = repProfile.GetAll(); 
       var profiles = taskProfiles.Result; 
       if (profiles.Any()) 
       { 
        await repProfile.Modify(this.ModifiedInstance); 
       } 
       else 
       { 
        await repProfile.Add(this.ModifiedInstance, this.currentlyLoggedUser); 
       } 
       UserMessageBox.ShowError(Resources.Save, Resources.SaveSucceed, MessageBoxType.Information); 
       this.LoadingOff(); 

      } 
      catch (Exception e) 
      { 
       throw e; 
      } 

     } 

     public async void NextStep() 
     { 
      try 
      { 
       this.SaveData(); 

      } 
      catch (Exception ex) 
      { 
       UserMessageBox.ShowError(Resources.SaveFailed, ex.Message); 
      } 
     } 
    } 

私はCreditCardConfigurationやVM(IConfigurationの実装)、SenderAddress、ReceiverAddressなどのビューも作成しました。すべてのVMは、indexOrder(int)のプロパティを持ちます。

私の質問は、MainStateControlRegionの内容を変更するNextStepCommandを準備する方法です。ビューは特定の順序で利用可能でなければなりません。 indexOrder = 0のプロファイルが完成した場合、indexOrder = 1で次のViewに行くことができます。 NextStepCommandを実行した後、プロファイルのみを保存しました。 RegionNames.MainTabControlRegionのコンテンツをリロードする方法は?これらのビューの順序付けを実装する方法は?

ご協力いただきありがとうございます。

答えて

関連する問題