I'm attempting to essentially wrap the contents of a DataTemplate
in a ListView
GridViewColumn
with a border. What I want to know is if it's possible to supply an adorner that will surround that template so that I don't have to specify the border in every single DataTemplate
on every column (which is what I'm doing now). I've got something like this, but I know it's not right:
<Style TargetType="{x:Type Lis开发者_如何学编程tBoxItem}">
<Setter Property="TemplateContent">
<Setter.Value>
<ControlTemplate>
<StackPanel>
<Border BorderBrush="Green" BorderThickness="1">
<AdornedElementPlaceholder />
</Border>
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
This complains that the TemplateContent
is not a valid type. I've also tried with DataTemplate
and that doesn't work either (understandably so).
I know I could just create a DataTemplate
, however the content for each column is different. At the very least, it binds to different fields. I'm wondering if there's a solution using a dynamic resource, but I don't know much about it. Thanks for your help
EDIT: here's a sample of my ListView
:
<ListView ItemsSource="{Binding Path=OrderLines}"
ItemContainerStyle="{StaticResource ResourceKey=ListViewItemContainerStyle}">
<ListView.View>
<GridView>
<GridViewColumn>
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBox MaxWidth="30" Width="30" MaxLength="2"
Text="{Binding Path=Quantity,ValidatesOnDataErrors=True}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridView>
<ListView.View>
</ListView>
Essentially I want to wrap that text box in the DataTemplate
and any other items in additional columns.
The property needs to be "Template". See here for an example: http://msdn.microsoft.com/en-us/library/ms750821.aspx
精彩评论