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 733465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:15:39+00:00 2026-05-14T07:15:39+00:00

I am very new to WPF and needed some pointers as to why this

  • 0

I am very new to WPF and needed some pointers as to why this is not working correctly.

I am trying to make a maximize button that will change to a restore button when clicked. I thought a toggle button with 2 different styles that would be changed in the code behind could work. I am first trying to get the maximize button working and have ran into a problem. I get the error ‘System.Windows.Controls.Image’ is not a valid value for the ‘System.Windows.Controls.Image.Source’ property on a Setter. in my xaml. I seem to be not understanding something completely. Any help would be most helpful 🙂

Ryan

<Style x:Key="Maximize" TargetType="{x:Type ToggleButton}">
            <Style.Resources>
                <Image x:Key="MaxButtonImg" Source="/Project;component/Images/maxbutton.png" />
                <Image x:Key="MaxButtonHighlight" Source="/Project;component/Images/maxbutton-highlight.png" />
            </Style.Resources>
            <Setter Property="ContentTemplate">
                <Setter.Value>
                    <Image>
                        <Image.Style>
                            <Style TargetType="{x:Type Image}">
                                <Setter Property="Source" Value="{DynamicResource MaxButtonImg}"/>
                                <Style.Triggers>
                                    <Trigger Property="IsMouseOver" Value="True">
                                        <Setter Property="Source" Value="{DynamicResource MaxButtonHighlight}"/>
                                    </Trigger>
                                </Style.Triggers>
                            </Style>
                        </Image.Style>
                    </Image>
                </Setter.Value>
            </Setter>
        </Style>


<ToggleButton Name="MaxButton" Width="31" Height="31" BorderThickness="0" Click="MaxButton_Click" Margin="0,0,10,0" Tag="Max" 
                      Style="{DynamicResource Maximize}" />

My code behind would do something simple like this:

private void MaxButton_Click(object sender, RoutedEventArgs e)
    {
        ToggleButton tg = (ToggleButton)sender;

        if ( tg.IsChecked == true) {
            tg.Style = (Style)FindResource("Restore");
            this.WindowState = WindowState.Maximized;

        } else {
            tg.Style = (Style)FindResource("Maximize");
            this.WindowState = WindowState.Normal;
        }
    }
  • 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-14T07:15:39+00:00Added an answer on May 14, 2026 at 7:15 am

    You don’t want to change the image on mouse over. I added my images to a folder called Images in the project and set build action on the images to Resource.

    <Window.Resources>
    
            <Image x:Key="minImage" Source="/Images/min.png" Height="16" Width="16" />
            <Image x:Key="maxImage" Source="/Images/max.png" Height="16" Width="16" />
    
            <Style TargetType="{x:Type ToggleButton}" x:Key="minMaxButtonStyle">
                <Setter Property="Content" Value="{DynamicResource minImage}" />
                <Style.Triggers>
                    <Trigger Property="IsChecked" Value="True">
                        <Setter Property="Content" Value="{DynamicResource maxImage}" />
                    </Trigger>
                </Style.Triggers>
            </Style>
    
        </Window.Resources>
    
        <StackPanel>
    
            <ToggleButton Style="{StaticResource minMaxButtonStyle}" />
    
        </StackPanel>
    
    </Window>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm VERY new to WPF, and still trying to wrap my head around binding
I am very new to WPF and I am a bit stuck. I'm trying
I'm very new to WPF, so I've just started making a very simple Memory
I'm very new in WPF. I've got a ListBox where I want to set
I'm very new to WPF, so please bear with me. Basically I have defined
I'm very new to WPF: I need to have buttons on a grid resize
I am very new to WPF. The UI I was required to implement makes
i'm new to the realm to working with Files in .NET I'm creating a
Keeping in mind what CannibalSmith once said - All the answers are saying WPF

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.