Click here to Skip to main content
14,924,198 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Want to create a listview by Extending the The listview control. I have to create a unique style for my custom listview. The problem I am facing is
when am putting a gridview to arrange the data, the style that i applied will loss and it wil look like the ordinary listview.

Here i am displaying some of the sample that i tried.

In the Xaml file where i designed my listview

<Style TargetType="{x:Type local:GOGWPFAdvancedListView}">
     <Setter Property="Template">
             <ControlTemplate TargetType="{x:Type local:GOGWPFAdvancedListView}">
                 <Border removed="LightBlue"

I Extended a class for my listview

public class GOGWPFAdvancedListView : System.Windows.Controls.ListView
static GOGWPFAdvancedListView()
DefaultStyleKeyProperty.OverrideMetadata(typeof(GOGWPFAdvancedListView), new System.Windows.FrameworkPropertyMetadata(typeof(GOGWPFAdvancedListView)));


In my Consuming Page


when i put only the new control its style is visible
<advanced:gogwpfadvancedlistview name="lvMainlist" >

But when i put a gridview to the listview it wil look like the ordinary listview

<advanced:gogwpfadvancedlistview name="lvMainlist" >
                    <gridviewcolumn header="Name" width="100" displaymemberbinding="{Binding Name}" />
                    <gridviewcolumn header="Place" width="100" displaymemberbinding="{Binding Place}" />
                    <gridviewcolumn header="Country" width="100" displaymemberbinding="{Binding Country}" />
                    <gridviewcolumn header="State" width="100" displaymemberbinding="{Binding State}" />
                    <gridviewcolumn header="Age" width="100" displaymemberbinding="{Binding Age}" />
                    <gridviewcolumn header="C/O" width="100" displaymemberbinding="{Binding CO}" />
                    <gridviewcolumn header="JOB" width="100" displaymemberbinding="{Binding JOB}" />

Any suggestions???
Updated 30-Jun-14 18:20pm
azweepay 11-Jul-14 2:56am
What do you mean exactly when you say "But when i put a gridview to the listview it wil look like the ordinary listview"? That the Blue border style you applied isn't showing anymore? I can't seem to reproduce it.

1 solution

After a quick look I think you are missing a TemplateBinding, when you set the Content of your ListView it should set it to the Content of your border in the ControlTemplate, shouldn't it?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900