代码之家  ›  专栏  ›  技术社区  ›  Timothy Khouri

如何找到ItemTemplate中的“复选框”项?

  •  26
  • Timothy Khouri  · 技术社区  · 17 年前

    我有以下(非常简单的)Items控件:

    <ItemsControl Name="BlahList" ItemsSource="{Binding Blah}">
        <ItemsControl.ItemTemplate>
            <DataTemplate>
                <CheckBox Name="MyCheckBox" Content="{Binding Text}" />
            </DataTemplate>
        </ItemsControl.ItemTemplate>
    </ItemsControl>
    

    在代码中,我想做以下事情:

    foreach (var dahCurrentItem in BlahList.Items)
    {
        var ItemCheckBox = BlahList.GimmeMyControl(dahCurrentItem, "MyCheckBox")
    
        // I'm going to do something with the check box here...
    }
    

    我该怎么做?

    4 回复  |  直到 7 年前