0

私は WPF アプリケーションに Catel を使い始めたばかりで、いくつかの問題があります。

1) ボタンが実行できない場合、ドキュメントに従ってボタンがグレー表示されません。

2) データベースに値を永続化するためのコードを配置する場所 (ViewModel または Model)。どこかに例はありますか?

3) メイン ページでメニューを使用し、メニュー項目のクリックでユーザー コントロールを読み込む例はありますか?

4) ViewModel のコンストラクターで DeferValidationUntilFirstSaveCall = true を設定すると、ダイアログ ウィンドウが表示されたときに例外が発生します。例外は次のとおりです

System.NullReferenceException was unhandled by user code
  HResult=-2147467261
  Message=Object reference not set to an instance of an object.
  Source=Catel.MVVM
  StackTrace:
       at Catel.Windows.Data.Converters.GetFirstValidationErrorConverter.Convert(Object value, Type targetType, Object parameter)
       at Catel.Windows.Data.Converters.ValueConverterBase.Convert(Object value, Type targetType, Object parameter, CultureInfo culture)
       at System.Windows.Data.BindingExpression.TransferValue(Object newValue, Boolean isASubPropertyChange)
       at System.Windows.Data.BindingExpression.Activate(Object item)
       at System.Windows.Data.BindingExpression.AttachToContext(AttachAttempt attempt)
       at System.Windows.Data.BindingExpression.AttachOverride(DependencyObject target, DependencyProperty dp)
       at System.Windows.Data.BindingExpressionBase.OnAttach(DependencyObject d, DependencyProperty dp)
       at System.Windows.StyleHelper.GetInstanceValue(UncommonField`1 dataField, DependencyObject container, FrameworkElement feChild, FrameworkContentElement fceChild, Int32 childIndex, DependencyProperty dp, Int32 i, EffectiveValueEntry& entry)
       at System.Windows.StyleHelper.GetChildValueHelper(UncommonField`1 dataField, ItemStructList`1& valueLookupList, DependencyProperty dp, DependencyObject container, FrameworkObject child, Int32 childIndex, Boolean styleLookup, EffectiveValueEntry& entry, ValueLookupType& sourceType, FrameworkElementFactory templateRoot)
       at System.Windows.StyleHelper.GetChildValue(UncommonField`1 dataField, DependencyObject container, Int32 childIndex, FrameworkObject child, DependencyProperty dp, FrugalStructList`1& childRecordFromChildIndex, EffectiveValueEntry& entry, ValueLookupType& sourceType, FrameworkElementFactory templateRoot)
       at System.Windows.StyleHelper.GetValueFromStyleOrTemplate(FrameworkObject fo, DependencyProperty dp, EffectiveValueEntry& entry)
       at System.Windows.StyleHelper.ApplyStyleOrTemplateValue(FrameworkObject fo, DependencyProperty dp)
       at System.Windows.StyleHelper.InvalidateContainerDependents(DependencyObject container, FrugalStructList`1& exclusionContainerDependents, FrugalStructList`1& oldContainerDependents, FrugalStructList`1& newContainerDependents)
       at System.Windows.StyleHelper.DoStyleInvalidations(FrameworkElement fe, FrameworkContentElement fce, Style oldStyle, Style newStyle)
       at System.Windows.StyleHelper.UpdateStyleCache(FrameworkElement fe, FrameworkContentElement fce, Style oldStyle, Style newStyle, Style& styleCache)
       at System.Windows.FrameworkElement.OnStyleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
       at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
       at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
       at System.Windows.Controls.TextBox.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
       at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
       at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
       at System.Windows.DependencyObject.InvalidateProperty(DependencyProperty dp, Boolean preserveCurrentValue)
       at System.Windows.FrameworkElement.UpdateStyleProperty()
       at System.Windows.FrameworkElement.OnInitialized(EventArgs e)
       at System.Windows.FrameworkElement.TryFireInitialized()
       at System.Windows.FrameworkElement.EndInit()
       at MS.Internal.Xaml.Runtime.ClrObjectRuntime.InitializationGuard(XamlType xamlType, Object obj, Boolean begin)
       at MS.Internal.Xaml.Runtime.PartialTrustTolerantRuntime.InitializationGuard(XamlType xamlType, Object obj, Boolean begin)
       at System.Xaml.XamlObjectWriter.Logic_EndInit(ObjectWriterContext ctx)
       at System.Xaml.XamlObjectWriter.WriteEndObject()
       at System.Xaml.XamlWriter.WriteNode(XamlReader reader)
       at System.Windows.Markup.WpfXamlLoader.TransformNodes(XamlReader xamlReader, XamlObjectWriter xamlWriter, Boolean onlyLoadOneNode, Boolean skipJournaledProperties, Boolean shouldPassLineNumberInfo, IXamlLineInfo xamlLineInfo, IXamlLineInfoConsumer xamlLineInfoConsumer, XamlContextStack`1 stack, IStyleConnector styleConnector)
       at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
       at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
       at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
       at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
       at FNZCIressClient.Views.AccountMappingWindow.InitializeComponent() in h:\Documents\iress-utils\FNZCIressClient\FNZCIressClient\Views\AccountMappingWindow.xaml:line 1
       at FNZCIressClient.Views.AccountMappingWindow..ctor(AccountMappingViewModel viewModel) in h:\Documents\iress-utils\FNZCIressClient\FNZCIressClient\Views\AccountMappingWindow.xaml.cs:line 28
  InnerException: 

コードから defervalidation 行を削除すると、ポップアップが機能します。

ヘルプとアドバイスをいただければ幸いです。

4

1 に答える 1

0

1)サンプル リポジトリを見てください。たくさんのサンプルがあります。

2) Save() メソッドをオーバーライドする

3) UIVisualizerService または Prism を使用して領域を動的にロードする

4) 私はこれを調べます。データウィンドウまたはカスタムのデータウィンドウを使用していますか?

于 2013-08-07T06:35:32.420 に答える