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

  • Home
  • SEARCH
  • 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 6563043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:46:56+00:00 2026-05-25T13:46:56+00:00

The xaml below is for a Window I am using in several presentations where

  • 0

The xaml below is for a Window I am using in several presentations where the only thing that varies is the UserControl that it hosts:

    <Window x:Class="Smack.ConstructionAdmin.Presentation.Wpf.Views.Admin.Employees.EmployeeShellView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:local="clr-namespace:Smack.ConstructionAdmin.Presentation.Wpf.Views.Admin.Employees" 
        xmlns:s="clr-namespace:Smack.ConstructionAdmin.Presentation.Wpf" 
        xmlns:cmdRef="clr-namespace:Smack.Core.Presentation.Wpf.ViewModels.Commands.Reference;assembly=Smack.Core.Presentation.Wpf" 

        Background="{DynamicResource WaveWindowBackground}"
        Title="{Binding Source={x:Static s:Strings.AppName}}"  
        Icon="pack://application:,,,/Smack.ConstructionAdmin.Presentation.Wpf;component/Images/Time-Machine_16.png"
        FontFamily="Arial"  
        WindowStartupLocation="CenterScreen" Width="750" Height="600" 
        >
    <DockPanel>
        <local:EmployeeShellUserControl DataContext="{Binding}"  />
    </DockPanel>

    <Window.InputBindings>
        <cmdRef:KeyBindingEx  CommandReference="{Binding AddCommand}"/>
        <cmdRef:KeyBindingEx  CommandReference="{Binding EditCommand}"/>
        <cmdRef:KeyBindingEx  CommandReference="{Binding DeleteCommand}"/>
    </Window.InputBindings>

</Window>

So it seems to make sense to reuse the parts that do not vary somehow. Here is my first attempt at doing so with a style:

<Style x:Key="MyWindowStyle" TargetType="{x:Type Window}">
    <Setter Property="Background" Value="{DynamicResource WaveWindowBackground}"></Setter>
    <Setter Property="FontFamily" Value="Arial"></Setter>
    <Setter Property="Height" Value="600"></Setter>
    <Setter Property="Width" Value="750"></Setter>
    <Setter Property="Title" Value="{Binding AppName}"></Setter>
    <Setter Property="Icon" Value="{Binding IconUri}"></Setter>
</Style>

Pain points

  1. I couldn’t find a property setter for WindowStartupLocation
  2. I don’t see how to make the InputBindings part of the style

IS using a style the right approach or is there some other technique I need to use? How can I set the above properties?

Cheers.
Berryl

  • 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-05-25T13:46:57+00:00Added an answer on May 25, 2026 at 1:46 pm

    Why don’t you simply create a window of this type without content, and then add the UserControl of your choice as its Content before showing it? You won’t need multiple Window subclasses, and you won’t need to mess with styles.

    A trivial example, where we ‘re setting the window’s content to a string (normally you ‘d use some appropriate UserControl):

    var window = new EmployeeShellView();
    window.Content = "Hello world!"; // set to your UserControl
    window.Show();
    

    If you want to insert a complex UserControl, say this one:

    <UserControl x:Class="MyControl">
        <DockPanel>
            <local:EmployeeShellUserControl DataContext="{Binding}"  />
        </DockPanel>
    </UserControl>
    

    You would do:

    var window = new EmployeeShellView();
    window.Content = new MyControl();
    window.Show();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have below XAML code : <Window x:Class=WpfApplication1.Window1 xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml DataContext={Binding RelativeSource={RelativeSource Self}} WindowStartupLocation=CenterScreen
I have a UserControl (XAML below) that has a ListBox that I want to
I have XAML File as below: <Window x:Class=ComboBoxCheck.Window1 xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml xmlns:check=clr-namespace:ComboBoxCheck Title=Window1 Height=300 Width=320>
XAML allows you to specify an attribute value using a string that contains curly
The XAML below does not work (the text does not change when mousing over):
The following XAML (below) defines a custom collection in resources and attempts to populate
The labels in the example below (WPF/XAML) just parade off the screen, no wrapping
I'm trying to host an XNA game inside a WPF window using the Windows
I would like to build a WPF window application using the following layout structure.
I'm working on a WPF application that has no main window (it runs in

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.