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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:58:36+00:00 2026-05-23T15:58:36+00:00

I have a Dock Panel and I want to set its height depending on

  • 0

I have a Dock Panel and I want to set its height depending on a Property value.

The following compiles, but does not execute :

<DockPanel Grid.Row="1"
            Visibility="{Binding Path=IsValid}" Margin="8,4">
            <DockPanel.Triggers>
                <Trigger Property="FrameworkElement.Visibility" Value="Visible">
                    <Setter Property="FrameworkElement.Height" Value="150"/>
                </Trigger>
                <Trigger Property="FrameworkElement.Visibility" Value="Hidden">
                    <Setter Property="FrameworkElement.Height" Value="0"/>
                </Trigger>
            </DockPanel.Triggers>
            <ListBox Height="150"/>
        </DockPanel>

What am I doing wrong? Any help, greatly appreciated.

Thanks

Joe

  • 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-23T15:58:37+00:00Added an answer on May 23, 2026 at 3:58 pm

    From MSDN:

    Note that the collection of triggers established on an element only supports EventTrigger, not property triggers (Trigger). If you require property triggers, you must place these within a style or template and then assign that style or template to the element either directly through the Style property, or indirectly through an implicit style reference.

    So, for this to work you need a Style or a Template. I don’t think you wish to change the way your DockPanel looks, so Style it is:

    <DockPanel Grid.Row="1" Visibility="{Binding Path=IsValid}" Margin="8,4">
        <DockPanel.Style>
           <Style>
               <Style.Triggers>
                   <Trigger Property="FrameworkElement.Visibility" Value="Visible">
                       <Setter Property="FrameworkElement.Height" Value="150"/>
                   </Trigger>
                   <Trigger Property="FrameworkElement.Visibility" Value="Hidden">
                       <Setter Property="FrameworkElement.Height" Value="0"/>
                   </Trigger>
               </Style.Triggers>
           </Style>
        </DockPanel.Style>
    
        <ListBox Height="150"/>
    </DockPanel>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to set the Source of an Image depending of the value of
When i write something like this: <Style x:Key=panelS> <Setter Property=Orientation Value=Horizontal /> <Setter Property=DockPanel.Dock
I have a main application window that also implements a dock panel. At the
Depending on the IsEnabled property of my UserControl (true/false), I want the controls inside
I have created a listbox control with following DataTemplate <DataTemplate x:Key=lb_Itemtemplate> <DockPanel> <TextBlock Text={Binding}
I seem to have the exact opposite problem than this question on stopping dock
I have an ObservableCollection<Object> that contains two different types. I want to bind this
I have the following method in my WPF project (.net 4): private void MyMethod(){
I want in the window of a wpf to set a treeview and make
I have a scenerio where I want to dynamically render a custom form object.

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.