在列表框模板WPF中查找控件

时间:2013-05-25 08:58:28

标签: wpf

循环浏览Listbox items并尝试获取checkbox控件但我无法找到。我的XAML代码如下所示。

<ListBox Height="119" HorizontalAlignment="Left" ItemsSource="{Binding Path=mastertable}" Margin="193,10,0,0" Name="lstMyItems" VerticalAlignment="Top" Visibility="Hidden" Width="120" FontSize="12" FontWeight="Normal">
                        <ListBox.ItemTemplate>
                            <DataTemplate x:Name="DataTemplete">
                                <CheckBox Name="chkIsselect"   Margin="0,5,0,0"  Content="{Binding ItemName}"  Click="chkIsselect_Click"/>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>

和c#代码

  for (int i = 0; i < lstMyItems.Items.Count; i++)
 {
         // Here I need acces to Checkbox.
 }

0 个答案:

没有答案