Expander Header Content Stretch
-
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.
-
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.
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
-
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
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.