Click here to Skip to main content
14,738,277 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to Create a Customized Combobox by extending the WPF Combobox. I like to create a template for it
On the DropDown of the combobox it must have
1) Listview
2) Button
Help me to create that

I tried like this
Created a xaml file to create a template
<Style TargetType="ComboBoxItem" x:Name="CombowithList">
        <Setter Property="ContentTemplate">
            <Setter.Value>
                <DataTemplate>
                    <Border>
                        <ScrollViewer>
                            <ListView x:Name="lvMainList" Width="400" Height="70">
                                <ListView.View>
                                    <GridView>
                                        <GridViewColumn Header="Name" Width="150" DisplayMemberBinding="{Binding Name}"/>
                                        <GridViewColumn Header="Place" Width="150" DisplayMemberBinding="{Binding Place}"/>
                                        <GridViewColumn Header="ID" Width="100" DisplayMemberBinding="{Binding ID}"/>
                                    </GridView>
                                </ListView.View>
                            </ListView>
                        </ScrollViewer>
                    </Border>
                </DataTemplate>
            </Setter.Value>
        </Setter>
    </Style>

And Created a class to access this style

public class GOGWPFFilterCombo : System.Windows.Controls.ComboBox
    { 
public GOGWPFFilterCombo()
        

this.ItemContainerStyle = this.FindResource("CombowithList") as System.Windows.Style;

            _dtToBind = new System.Data.DataTable();
            _dtToBind.Columns.Add("Name");
            _dtToBind.Columns.Add("Place");
            _dtToBind.Columns.Add("ID");

            System.Data.DataRow dr = _dtToBind.NewRow();
            dr["Name"] = "James";
            dr["Place"] = "USA";
            dr["ID"] = "121";
            _dtToBind.Rows.Add(dr);
            this.ItemsSource = _dtToBind.DefaultView;}
}
}



This is the Sample Code am trying; It is only on progress now
Posted
Updated 18-Jun-14 4:38am
v6
Comments
agent_kruger 18-Jun-14 9:16am
   
sir i cannot understand where is the problem?
joshrduncan2012 18-Jun-14 9:20am
   
What is your question? Where are you stuck? Show us your code of your attempt to fulfill this requirement. Are you getting any errors? If so, what is the text of the error?

1 solution

   

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