Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7947079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:19:48+00:00 2026-06-04T01:19:48+00:00

When I attempt to set the WindowStartupLocation property through a Setter within a ResourceDictionary

  • 0

When I attempt to set the WindowStartupLocation property through a Setter within a ResourceDictionary, I get a XamlParseException:

‘Set property ‘System.Windows.Setter.Property’ threw an exception.’ Line number ‘x’ and line position ‘y’.

The inner exception is an ArgumentNullException:

Value cannot be null. Parameter name: property.

My style within the resource dictionary is:

<Style TargetType="Window" x:Key="WindowStyle">
    <Setter Property="SizeToContent" Value="WidthAndHeight" />
    <Setter Property="ResizeMode" Value="CanMinimize" />
    <Setter Property="WindowStartupLocation" Value="CenterOwner" />
</Style>

The issue is not with the use of the ResourceDictionary, since when I remove the WindowStartupLocation, the other two properties (SizeToContent and ResizeMode) are set as expected on windows which reference the style:

<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>

Has anyone encountered this? Is it a bug/limitation of WPF?

P.S. I know that this question is similar to Window Startup Location from resource dictionary, but not enough information was provided in the other question which subsequently remained unsolved.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T01:19:50+00:00Added an answer on June 4, 2026 at 1:19 am

    The problem is that WindowStartupLocation is not a DependencyProperty so you can’t set it in the style setter. Looking in ILSpy the Setter calls

    CheckValidProperty(DependencyProperty property)
    

    and throws a NullArgumentException.

    As WindowStartupLocation is just a CLR property, it can’t be set in this way.

    However, you can still use a ResourceDictionary:

    <Application.Resources>
        <ResourceDictionary>
            <Style x:Key="WindowStyle" TargetType="Window">
                <Setter Property="SizeToContent" Value="WidthAndHeight" />
                <Setter Property="ResizeMode" Value="CanMinimize" />
            </Style>
            <WindowStartupLocation x:Key="WSL">CenterOwner</WindowStartupLocation>
        </ResourceDictionary>
    </Application.Resources>
    
    <Window x:Class="WpfApplication7.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"            
            WindowStartupLocation="{StaticResource WSL}"
            Style="{StaticResource WindowStyle}" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm consistently running into an invalid selector exception when I attempt to set multiple
Whenever I attempt to set content view after dismissing the progress dialog I get
in an attempt to see and hopefully understand actionscript's garbage collector, i've set up
When I attempt to debug a simple program with gdb on cygwin I get
Whenever I attempt to set the default value of an optional parameter to something
My current code to attempt to set widths for the rows on a gridview
When I attempt to set an application role on a SqlConnection with sp_setapprole I
I have the following code in my application:DidFinishLaunchingWithOptions: where I attempt to set tab
I get a compile error, Cannot implicitly conver type 'System.Collections.ObjectModel.ObservableCollection to ProddataRecsObservable'. An explicit
In jqGrid, when you attempt to delete a row or set of rows, a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.