Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. Expander Header Content Stretch

Expander Header Content Stretch

Scheduled Pinned Locked Moved WPF
wpfhelpcsswcfquestion
3 Posts 2 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Kevin Marois
    wrote on last edited by
    #1

    I've got a listbox with expanders[^] in it. The problem is that expander's header content is not stretched. I've tried all kinds of things, but I can't seem to get it. Here's the XAML

    <Expander Padding="{Binding Padding, RelativeSource={RelativeSource TemplatedParent}}"
    Margin="{Binding Margin, RelativeSource={RelativeSource TemplatedParent}}"
    BorderBrush="{Binding BorderBrush, RelativeSource={RelativeSource TemplatedParent}}"
    BorderThickness="{Binding BorderThickness, RelativeSource={RelativeSource TemplatedParent}}"
    ScrollViewer.HorizontalScrollBarVisibility="Auto"
    ScrollViewer.VerticalScrollBarVisibility="Auto"
    IsExpanded="{Binding IsPaneExpanded, RelativeSource={RelativeSource TemplatedParent}}">

    <Expander.Header>
    
        <Grid>
    
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="\*"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
    
            <TextBlock Text="{Binding Header}"
                    HorizontalAlignment="Left"
                    VerticalAlignment="Center"
                    Margin="1"/>
    
            <Button Grid.Column="1"
                    Height="18"
                    Width="18"
                    Margin="0,1,1,1"/>
    
        </Grid>
    
    </Expander.Header>
    
    <CONTENT REMOVED FOR BREVITY>
    

    </Expander>

    If it's not broken, fix it until it is. Everything makes sense in someone's mind. Ya can't fix stupid.

    Richard DeemingR 1 Reply Last reply
    0
    • K Kevin Marois

      I've got a listbox with expanders[^] in it. The problem is that expander's header content is not stretched. I've tried all kinds of things, but I can't seem to get it. Here's the XAML

      <Expander Padding="{Binding Padding, RelativeSource={RelativeSource TemplatedParent}}"
      Margin="{Binding Margin, RelativeSource={RelativeSource TemplatedParent}}"
      BorderBrush="{Binding BorderBrush, RelativeSource={RelativeSource TemplatedParent}}"
      BorderThickness="{Binding BorderThickness, RelativeSource={RelativeSource TemplatedParent}}"
      ScrollViewer.HorizontalScrollBarVisibility="Auto"
      ScrollViewer.VerticalScrollBarVisibility="Auto"
      IsExpanded="{Binding IsPaneExpanded, RelativeSource={RelativeSource TemplatedParent}}">

      <Expander.Header>
      
          <Grid>
      
              <Grid.ColumnDefinitions>
                  <ColumnDefinition Width="\*"/>
                  <ColumnDefinition Width="Auto"/>
              </Grid.ColumnDefinitions>
      
              <TextBlock Text="{Binding Header}"
                      HorizontalAlignment="Left"
                      VerticalAlignment="Center"
                      Margin="1"/>
      
              <Button Grid.Column="1"
                      Height="18"
                      Width="18"
                      Margin="0,1,1,1"/>
      
          </Grid>
      
      </Expander.Header>
      
      <CONTENT REMOVED FOR BREVITY>
      

      </Expander>

      If it's not broken, fix it until it is. Everything makes sense in someone's mind. Ya can't fix stupid.

      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #2

      Stretching Content in an Expander Header | Josh Smith on WPF[^] The width binding trick won't work, as it will push the button outside of the available space. But the code-behind trick should be OK.


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      K 1 Reply Last reply
      0
      • Richard DeemingR Richard Deeming

        Stretching Content in an Expander Header | Josh Smith on WPF[^] The width binding trick won't work, as it will push the button outside of the available space. But the code-behind trick should be OK.


        "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

        K Offline
        K Offline
        Kevin Marois
        wrote on last edited by
        #3

        That did it. I saw this article already and tried the XAML approach. I should have hep reading. Thanks

        If it's not broken, fix it until it is. Everything makes sense in someone's mind. Ya can't fix stupid.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups