Is it possible to style the contents of a DockPanel to fill the last
*visible* child?
Consider this XAML snippet...
<DockPanel x:Name="TestDockPanel">
<Button x:Name="RightButton" Content="Right" DockPanel.Dock="Right" />
<Button x:Name="FillButton" Content="Fill" />
</DockPanel>
As written, the DockPanel will layout 'RightButton' to the right, then
fill the rest of the area with 'FillButton' like this...
We're trying to find a way to style it so that when 'FillButton' has its
visibility changed to 'Collapsed', 'RightButton' should now fill the area,
like this...
The only way we know how to do this is to physically remove 'FillButton'
from the children of 'TestDockPanel' but that requires code-behind, which
we're trying to avoid.
Update
Below in an answer, I've posed a solution based on a subclass. However,
I'm leaving this open since I'd like something that can be used with any
DockPanel (or other subclass) and preferrably applied via a style or an
attached behavior. Also, to be clear, a requirement of the solution is
that it must be based on a DockPanel, not a grid or other panel.
No comments:
Post a Comment