How to write style template to Popup control?
I'd recommend wrapping your Popup's Content in something like a ContentControl
or a HeaderedContentControl
and setting the style of that
<Popup>
<ContentControl Style="{StaticResource PopupContentStyle}">
...
</ContentControl>
</Popup>
Example style...
<Style x:Key="PopupContentStyle" TargetType="{x:Type ContentControl}">
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<Grid Width="Auto" Height="Auto" Background="Gray">
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Border BorderThickness="2" CornerRadius="8" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.RowSpan="2">
<Border.BorderBrush>
<SolidColorBrush Color="Gray"/>
</Border.BorderBrush>
<Border.Background>
<SolidColorBrush Color="White"/>
</Border.Background>
</Border>
<StackPanel Grid.Row="0">
<Label Foreground="Blue" Content="Popup_Title"/>
</StackPanel>
<GroupBox Grid.Row="1" Header="Popup example content">
<StackPanel>
<ContentPresenter />
</StackPanel>
</GroupBox>
</Grid>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>