Is it possible to define the "presenting behavior" of a ContentPresenter
so that it applies padding to its content?
Now I have a ContentPresenter
and define the Margin on all UserControl
s that can be part of this ContentPresenter.
The downside of this, is that it calls for repeating definitions of Margins, and the UserControl
s are kind of dedicated to "fit" in the ContentPresenter
.
E.g. XAML that contains the content presenter:
<ContentPresenter
x:Name="SettingsContentPanel"
Grid.Row="0"
Grid.Column="2"
Grid.ColumnSpan="2"
Content="{Binding ElementName=SettingsGroupSelector, Path=SelectedItem.Tag}" />
And the user controls are defined as follows:
<UserControl
<!-- left out irrelevant definitions -->
Margin="5,5,5,5">
You should be able to get the effect you're after by setting the Margin
on your ContentPresenter
element itself e.g:
<ContentPresenter
x:Name="SettingsContentPanel"
Grid.Row="0"
Grid.Column="2"
Grid.ColumnSpan="2"
Content="{Binding ElementName=SettingsGroupSelector, Path=SelectedItem.Tag}"
Margin="5,5,5,5" />
Also, if the Margin
is the same on all sides, you could use the shorthand Margin="5"
.
Hope that helps =D