Hi all,
We have a lot of controls that consist of: A container with rounded borders and a couple of buttons that call save & cancel commands on the view model somthing like this:
<Border Background="White" CornerRadius="10" BorderBrush="Black" BorderThickness="1" Opacity="1" Padding="5,5,5,5" VerticalAlignment="Center" HorizontalAlignment="Center">
<StackPanel>
<!--Some Control Stuff Here...-->
<controls:SaveCancelButtons/>
</StackPanel>
</Border>
What I'd like to do is make a custom control/style/template etc that allows me to reuse this so I can just wrap any new user control in a set of tags that places its content into the stack panel (where the comment is above)
What's the best way of achiving this?
EDIT:
OK Now I have a template like so:
<ControlTemplate x:Key="RoundedBordersTemplate">
<Border Background="White" CornerRadius="10" BorderBrush="Black" BorderThickness="1" Opacity="1" Padding="5,5,5,5" VerticalAlignment="Center" HorizontalAlignment="Center">
<StackPanel>
<ContentPresenter/>
<controls:SaveCancelButtons/>
</StackPanel>
</Border>
</ControlTemplate>
And the control is implimented like so:
<ContentControl Template="{StaticResource RoundedBordersTemplate}">
<StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="Description: " Width="72"/>
<TextBox Text="{Binding Path=Description}"
Width="205" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="Type:" Width="72" />
<ComboBox ItemsSource="{Binding Path=TypeList}"
DisplayMemberPath="Description"
SelectedValuePath="ID"
Width="205" />
</StackPanel>
</StackPanel>
</ContentControl>
But I only see the Save/Cancel buttons.