tags:

views:

188

answers:

1

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.

A: 

The property needs to be "Template". See here for an example: http://msdn.microsoft.com/en-us/library/ms750821.aspx

Scott J
This doesn't appear to work, I think because it replaces the entire ListBoxItem/ListViewItem template -- so the green box goes round the entire row, not round each cell.
itowlson
I should mentioned that I mistyped and that the target type would be any ListVIEWItem and not ListBoxItem. As such, I can't seem to get this example to work. It will work for those items in a listview that are GridViewColumns however, all I see is the green border and the content is now gone. My listview has custom templates. I will update the main request with a sample of the code.How would I got about applying that style to singular listviews (ie - what is the property to bind the static resource to on the listview because it's not celltemplate).
Chris Cap