内でWindowStartupLocation
プロパティを設定しようとすると、次のようになります。Setter
ResourceDictionary
XamlParseException
'プロパティの設定'System.Windows.Setter.Property'が例外をスローしました。行番号「x」と行位置「y」。
内部の例外はArgumentNullException
:
値をnullにすることはできません。パラメータ名:プロパティ。
リソース辞書内の私のスタイルは次のとおりです。
<Style TargetType="Window" x:Key="WindowStyle">
<Setter Property="SizeToContent" Value="WidthAndHeight" />
<Setter Property="ResizeMode" Value="CanMinimize" />
<Setter Property="WindowStartupLocation" Value="CenterOwner" />
</Style>
ResourceDictionary
を削除すると、スタイルを参照するウィンドウでWindowStartupLocation
他の2つのプロパティ(SizeToContent
および)が期待どおりに設定されるため、問題はの使用ではありません。ResizeMode
<Window x:Class="WpfApplication1.MyWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Style="{DynamicResource WindowStyle}">
<Window.Resources>
<ResourceDictionary Source="MyResourceDictionary.xaml" />
</Window.Resources>
</Window>
誰かがこれに遭遇しましたか?WPFのバグ/制限ですか?
PSこの質問はリソースディクショナリのウィンドウ起動場所に似ていることは知っていますが、他の質問では十分な情報が提供されておらず、その後未解決のままでした。