I want to have a border around ListViewItem (a string in my case). ListView source and columns created at runtime. In XAML, I have this structure:
<ListView Name="listViewRaw">
<ListView.View>
<GridView>
</GridView>
</ListView.View>
</ListView>
At run time, I bind a listview to a DataTable, adding the necessary columns and bindings:
var view = (listView.View as GridView);
view.Columns.Clear();
for (int i = 0; i < table.Columns.Count; i++)
{
GridViewColumn col = new GridViewColumn();
col.Header = table.Columns[i].ColumnName;
col.DisplayMemberBinding = new Binding(string.Format("[{0}]", i.ToString()));
view.Columns.Add(col);
}
listView.CoerceValue(ListView.ItemsSourceProperty);
listView.DataContext = table;
listView.SetBinding(ListView.ItemsSourceProperty, new Binding());
So, I want to add a border around each row and set the border behavior (color, etc.) using DataTriggers (for example, if the value in the 1st column = "Visible", set the border color to black). Can I place a border through a DataTemplate in an ItemTemplate? I know a solution where you are manipulating with CellTemplates, but I don't really like it. I want something like this if possible.
<DataTemplate>
<Border Name="Border" BorderBrush="Transparent" BorderThickness="2">
<ListViewItemRow></ListViewItemRow>
</Border>
</DataTemplate>