vashma

how to access the child UI elements present in a listview as it is not a listview item i am unable to access it in the cs file
pls anyone help me



Re: Windows Presentation Foundation (WPF) how to access Listview Child elements

JoyK

<ListView Name ="lst">
<Button Name ="btn1" Content ="dg"/>
<Button Name ="btn2" Content="iaio"/>
</ListView>
<Button Content ="iter" Click ="clicked"/>

void clicked(object sender, RoutedEventArgs arg)
{
foreach (System.Windows.Controls.Control ct in lst.Items)
MessageBox.Show(ct.Name); //displays btn1 & btn2 since they r childrens
}

Hope this vl help u...

-Joy






Re: Windows Presentation Foundation (WPF) how to access Listview Child elements

vashma

thanks for ur reply joy

<ListView x:Name="StaffRecords" Height="Auto" ItemContainerStyle="{DynamicResource AltColorLVItemStyle2}" ScrollViewer.VerticalScrollBarVisibility="Auto" >

<ListView.GroupStyle>

<GroupStyle>

<GroupStyle.ContainerStyle>

<Style TargetType="{x:Type GroupItem}">

<Setter Property="Margin" Value="0,0,0,5"/>

<Setter Property="Template">

<Setter.Value>

<ControlTemplate TargetType="{x:Type GroupItem}" >

<Expander x:Name="StaffName" IsExpanded="True" BorderBrush="#FFA4B97F" BorderThickness="0,0,0,1" >

<Expander.Header>............

i am havin a expander in a listview and its not a listview item, as its not a listview item i cant access it in CS file

thanks

vash