Wrap or adorn wpf listview datatemplate
Posted
by Chris Cap
on Stack Overflow
See other posts from Stack Overflow
or by Chris Cap
Published on 2010-03-22T21:13:02Z
Indexed on
2010/03/22
22:31 UTC
Read the original article
Hit count: 864
I'm attempting to essentially wrap the contents of a DateTemplate in a listview gridview column 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 ListBoxItem}">
<Setter Property="TemplateContent">
<Setter.Value>
<ControlTemplate>
<StackPanel>
<Border BorderBrush="Green" BorderThickness="1">
<AdornedElementPlaceholder />
</Border>
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
This complains that 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 data template and any other items in additional columns.
© Stack Overflow or respective owner