.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Display ListView inside ListViewItem???

Posted By:      Posted Date: September 17, 2010    Points: 0   Category :WPF
Hi,   I was first using a tree view in order to display a two level hierarchical structure, however this was too slow (tree was taking up to 10 sec to display 3000 items). I believe that a listview will improve this performance. Is it possible to have a listview inside the listviewitem? So far I have this, the first level is being displayed, but no the second level Please help!! <ListBox x:Name="lstBoxHitList" Padding="5" Margin="1" ItemsSource="{x:Static local:Window1.SearchJobsList}" DockPanel.Dock="Bottom" MouseDoubleClick="tvHitList_MouseDoubleClick" TreeViewItem.Selected="tvHitList_Selected" ScrollViewer.HorizontalScrollBarVisibility="Disabled" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> <ListBox.Resources> <Style TargetType="ListBox" x:Key="ListBoxControlStyle" BasedOn="{StaticResource {x:Type ListBox}}"> <Style.Triggers> <DataTrigger Binding="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=Items.Count}" Value="0"> <Setter Property="Template"> <Setter.Value> <ControlTemplate>

View Complete Post

More Related Resource Links

Display the item in the ComboBox inside the ListView(GridView)

I have the below code used in binding the values to the ComboBox in GridView(ListView), please help me < ListView Margin="480,51,6,14" Name="grid1" ItemsSource="{Binding UserDetail}" IsSynchronizedWithCurrentItem="True" Width="389" Grid.Column="1" > <ListView.View> <GridView> <GridViewColumn Header="UserName" Width="120" DisplayMemberBinding="{Binding Path=WindowsUser}"/> <GridViewColumn Header="Role" Width="140"> <GridViewColumn.CellTemplate> <DataTemplate> <ComboBox Name="Rolecombo" Width="120" ItemsSource="{Binding Path=UserDetail}" SelectedValue="{Binding PFR_Tbl_Role.Role}"/> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> <GridViewColumn Header="Active" x:Name="column" Width="100"> <GridViewColumn.CellTemplate> <DataTemplate> <Grid Width="{Binding ElementName=column,Path=Width}"> <CheckBox IsChecked="{Binding Active}" HorizontalAlignment="Center" /> </Grid> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> </GridView>  </ListView.View> </ListView>

Display a nested child ListView on PostBack while using DataPager on parent ListView


Hello ASP.NET community,

I am having trouble finding how to solve the following issue :

I am using nested listviews to display Sales and Sales details.

The main ListView displays General Information about Sales and the child ListView displays the detailed information about one sale. the child listview is shown only when the user clicks on a link (see included code, DataBind is made on PageLoad) :

ASPX Markup Code :

<asp:listview id="lvSales" runat="server" onitemdatabound="lvSales_ItemDataBound">
<table cellspacing="0" border="1" width="250" style="border-collapse:collapse;">
<tr runat="server" id="headerRow">
<th scope="col" style="width:30px;"></th>
<th scope="col">SaleNumber</th>
<tr id="itemPlaceHolder" runat="server" enableviewstate="true"/>
<tr id="row" runat="server">
<td style="text-align:center;"><asp:button id="btnShowHideDetails" runat="server" oncommand=&qu

Microsoft ListView Control 6.0 cannot correctly display multibyte characters when running on a 64 bi

With all the regional settings set to Russian and the OS being Russion the ListView Control 6.0 does not display the column headers correctly on the Windows Server 2008 64 bit OS. If we switch to using Microsoft ListView Control, version 5 the columns (text strings) are displayed correctly. I am concerned that using an earlier version is going to cause problems. Is there a better solution other than using version 5? Thanks!

Editmode on GridView inside of ListView

I have a listview and inside the listview I have a gridview.  I'm binding data to the listview, then on the listview itemdatabound I'm binding the gridview. I want to make the gridview editable so I have an edit template and an edit command button.  I have the event rowediting and inside there I set the edit index. Now normally I rebind the control and everything works.  But if I rebind this gridview, nothing happens. I can trace through the rowediting and everything is working.  It's setting the edit index, it goes through the databind and gets the right data and binds it to the control. What is happening?  Why isn't my rebound edit mode gridview showing up?

Help Getting ListView To Display Data

I have years of Java experience but am new to .NET development.  I am currently working with C# and Microsoft Visual C# 2008.  Everything has been going well accept for one snag.  I can't get a ListView to display anything.  I've now spent hours on it and it seems I just don't get it.  Below is a sample program of my problem.  I am constructing the ListView in the Form constructor.  It's supposed to have 2 groups with 2 items, but when I run the program, the ListView is empty.  I've played around with trying different view types, but to no avail.  I've reduced it to the bare minimum and still don't get it.  What am I missing? using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace DemoFormApp { public partial class Form1 : Form { public Form1() { InitializeComponent(); ListViewGroup group1 = new ListViewGroup("Group One"); ListViewGroup group2 = new ListViewGroup("Group Two"); ListViewItem item1 = new ListViewItem("ABC"); ListViewItem item2 = new ListViewItem("CD"); group1.Items.Add(item1); group2.Items.Add(item2); listView1.Groups.Add(group1); listView1.Groups.Add(group

Remove a dynamically added ListViewItem from a ListView

Good day, In my xaml I have created a window in my app which contains a  ListView control. I have programmatically added ListViewItems. The ListViewItems each contain a grid. Grid column 0 contains a textblock, Grid column 1 contains a textbox and Grid column 2 contains a button. What I would like to do is click the button in the ListViewItems grid, and remove the ListViewItem in the button is contained from the ListView. Could anyone suggest a way to do this? I would really appreciate any advice, as this is crucial to the feature I am creating.

C# WPF ListView: ListViewItem content will not update?

I am having a problem updating a listview item which I have bindings set. Here is my XAML code and behind code. Also, the DownloadProgress and DownloadSize do not update but when I debug I see the changes made under the DownloadProgressChanged delegate: mtitem.dlbtn.MouseLeftButtonUp += delegate { MTDLItem dlitem = new MTDLItem(); dlitem.DownloadName = mtitem.tbmusicname.Text; dlitem.DownloadProgress = 0; dlitem.DownloadSize = ""; WebClient wc = new WebClient(); Uri webaddress = new Uri(mtitem.MusicLink); if (mtitem.Group == "5") { } else { string songtitle = mtitem.tbmusicname.Text + @".mp3"; string fixtitle = songtitle.Replace("\\", ""); if (Properties.Settings.Default.CopyRightMessage == false) { if (System.Windows.Forms.MessageBox.Show("GINtech Systems is not responsible for user applications of copyrighted music which may be in violation of existing local, state, or federal laws.", "MusicTuner Disclaimer", System.Windows.Forms.MessageBoxButtons.OKCancel, System.Windows.Forms.MessageBoxIcon.Exclamation) == System.Windows.F

disable autopostback of checkbox inside of GridView during SelectedIndexChanged of ListView

Hi, I hope my question is clear: I have a checkbox placed inside a gridview: <GridView><asp:TemplateField HeaderText="Driver">   <ItemTemplate>       <asp:CheckBox ID="CheckBoxDriver" AutoPostBack="true" OnCheckedChanged="GridView_Persons_SelectedIndexChanged" ValidationGroup='<%# Eval("ID") + "-" +((GridViewRow)Container).RowIndex %>' CssClass="CXDriver" runat="server" Checked='false' />   </ItemTemplate>       </GridView> For example: A listViewItem 1 has 3 drivers are checked, A listViewItem 2 has 2 drivers are checked. Therefore, if changing the selectedIndex of the list, the checkbox indexChanged event will be fired. How could I disable the autopostback of the checkbox during the listview item changed. Thanks in advance

Customizing the display for a ListView Web Part

I want to customize the display of a ListView Web Part. I tried following this [http://msdn.microsoft.com/en-us/library/ff604024.aspx] article, but I'm not having any success. Has anyone done something like this before? I need a very simple and basic view from which I can build upon. Like displaying only the Title field of a list without the column headers and other stuff. Thanks!

display color in textbox inside Gridview

Please let me know how to display background color of text box  inside a grid view.The Color value will be obtained from the DB.   eg. #00033

Imagebutton inside Listview inside another Listview

Hi,I'm trying to change the visibility of a imagebutton to false, if the imagebutton.ImageUrl="".The problem is that the imagebutton is inside "ListView2", and "ListView2" is inside "ListView1".Who can I do this in vb code... or even a javascript.Thanks

Finding a control inside a ListView on a master page

I have a listview on a master page that ISN'T part of a content place holder that I want to fill in and disable if the user is already logged in. I have a label set up already which works fine. I'm just having problems accessing a Textbox by the name of "NameTextBox" in the InsertItem template of the listview.Here is the part of my codefile:Dim vCurrentUser As MembershipUser = Membership.GetUser() If Not vCurrentUser Is Nothing Then Dim pnl As Label = LoginView1.FindControl("Label1") pnl.Text = Page.User.Identity.Name Dim NameBox As TextBox = ListView1.InsertItem.FindControl("NameTextBox") NameBox.Text = Page.User.Identity.Name End IfI get a Object not found exception. What is the correct way to find a control inside a InsertItemTemplate and the correct Event to use?

WPF - How to acces the tags of 3 comboboxes inside a ListViewItem


Hey I have the following problem:

I have a form with a ListView on it and this listview consists of listviewitems with some kind of template which is defined in the gridcolumn celltemplate.  The listview has elements of type "LeidingViewModel.cs" and that class consists of a Property Choices, which in turn consists of 3 observablecollections, which I want to bind on the 3 comboboxes inside the listviewitems. This isnt a problem, I know how to do this.

When I select something from the combobox I want the tag of the first combobox in a listviewitem to contain the choices of all 3 comboboxes together, I have done this using multibinding.  And now comes the problem: how can I acces the tag of the first combobox, when that combobox in fact is declared in a <DataTemplate> and referenced to from the ListView.View GridView.GridViewColumn.CellTemplate?.

Here's my code:

<Window ... xmlns:local="clr-namespace:PiconSalesWPF">

Page Up/Page Down scrolling behaviour with listview inside scrollviews


I have a listview with many list items that is contained within a scrollviewer.

When I select the topmost item and hit the Page Down key, the scrollviewer scrolls along with the listview. The same thing happens for combo boxes.

Is this the expected behaviour because I expected only the listview to scroll?

Here is some sample code:

<Window x:Class="WpfApplication1.Window1"

WPF: how to make the listview work (apply basic listviewitem style and also apply special data


 We have defined the basic ListViewIItemStyle as following:

<!--ItemContainerStyle with the Trigger for selection x:Key="ListViewItemStyle"-->
 <Style x:Key="ListViewItemStyle"
  TargetType="{x:Type ListViewItem}">
 <Setter Property="Background"
 Value="Transparent" />
 <Setter Property="HorizontalContentAlignment"
 Value="Center" />
 <Setter Property="VerticalContentAlignment"
 Value="Center" />
 <Setter Property="Foreground"
 Value="Black" />
 <Setter Property="Margin"
 Value="5,0,5,0" />
 <Setter Property="MinHeight"
 Value="40" />
 <Setter Property="Template">
 <ControlTemplate TargetType="{x:Type ListViewItem}">
 <Border x:Name="Bd"
 <GridViewRowPresenter VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
 <!--<ContentPresenter HorizontalAlignment="Left"
  SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />-->

change the forecolor of a text block inside a listView


Hello I'm new to WPF

I have a list view as follows:




<ListView Name

WPF: how to change the ListView cell template if the content is too long, it will display as Charact


We have used the GridView inside the ListView. We fix the column width (see the following link):


if the content is too long in one cell (since we fix the column width), we want it display as CharacterEllipsis at the end

just like the TextBlock we can define TextTrimming="CharacterEllipsis"

how can we achive it?


we have used the ListViewItemStyle as following, can we modify the <GridViewRowPresenter  /> section to achive it?

  <!--ItemContainerStyle with the Trigger for selection x:Key="ListViewItemStyle"-->
  <Style x:Key="ListViewItemStyle" TargetType="{x:Type ListViewItem}">
   <Setter Property="Background" Value="Transparent"/>
   <Setter Property="HorizontalContentAlignment" Value="Center"/>
   <Setter Property="VerticalContentAlignment" Value="Center"/>
   <Setter Property="Foreground" Value="Black"/>
   <Setter Property="Margin" Value="5,0,5,0&q
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend