Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8326751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:52:16+00:00 2026-06-09T00:52:16+00:00

I have this ListView: <ListView Grid.Row=1 x:Name=ListLinePositions ItemsSource={Binding Source={StaticResource CollectionViewSource}} SelectionChanged=ListLinePositions_SelectionChanged> <ListView.GroupStyle> <GroupStyle> <GroupStyle.ContainerStyle>

  • 0

I have this ListView:

 <ListView Grid.Row="1" x:Name="ListLinePositions" ItemsSource="{Binding Source={StaticResource CollectionViewSource}}" SelectionChanged="ListLinePositions_SelectionChanged">
        <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}" x:Name="posTemplate">
                                    <Grid Name="GridGroupItem">
                                        <Border Name="BorderGroupItem" CornerRadius="3" 
                                        BorderThickness="1" Padding="1,1,1,1" 
                                        Focusable="True" FocusVisualStyle="{x:Null}"
                                        Background="{StaticResource {x:Static SystemColors.GradientInactiveCaptionBrushKey}}"
                                        BorderBrush="{StaticResource {x:Static SystemColors.InactiveBorderBrushKey}}" PreviewMouseDown="BorderGroupItem_PreviewMouseDown">
                                            <Grid>
                                                <Grid.RowDefinitions>
                                                    <RowDefinition/>
                                                    <RowDefinition/>
                                                </Grid.RowDefinitions>
                                                <Grid Name="GridHeader" Grid.Row="0" Margin="0,2,0,2">
                                                    <Grid.ColumnDefinitions>
                                                        <ColumnDefinition/>
                                                        <ColumnDefinition Width="100"/>
                                                    </Grid.ColumnDefinitions>
                                                    <StackPanel Orientation="Horizontal" Grid.Column="0" Height="24">
                                                        <CheckBox x:Name="checkedHeader" VerticalAlignment="Center"/>
                                                        <TextBlock Text="{Binding Name.Id, Mode=OneWay}" FontWeight="Bold" Margin="3,0,3,0" VerticalAlignment="Center" />
                                                        <Image Height="24" Width="24" Source ="{Binding Name.Partition.Sport.TypeEnum, Converter={StaticResource SportTypeToImageConverter}, Mode=OneWay}" VerticalAlignment="Center" />
                                                    </StackPanel> 
                                                </Grid>
                                            </Grid>
                                        </Border>
                                    </Grid>                                        
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </GroupStyle.ContainerStyle>
            </GroupStyle>
        </ListView.GroupStyle>           

        <ListView.View>
            <GridView x:Name="positionGrid">
                <GridViewColumn Width="Auto" Header="check">
                    <GridViewColumn.CellTemplate>
                        <DataTemplate>
                            <CheckBox x:Name="checkedPosition" />
                        </DataTemplate>
                    </GridViewColumn.CellTemplate>
                </GridViewColumn>  
            </GridView>
        </ListView.View>
    </ListView>

I need to access <CheckBox x:Name="checkedPosition" />

My ListView loads in new window. So when I try to access the the CheckBox like this

foreach (LinePosition item in this.ListLinePositions.Items)
{
      CheckBox cb = FindByName("checkedPosition",
                                (ListViewItem)this.ListLinePositions.ItemContainerGenerator.ContainerFromItem(item)) as CheckBox;    
}

I can’t find anything although ListLinePositions.Items.Count > 0. But after ShowDialog for my window I get checked positions and this code works! I don’t know what to do in the first case. Please, help to find solution.

I had something like that

public LineHeaderViewDocument()
        {
            InitializeComponent();
            Title = GetTitle(_lineFilter);//изм
            ListLinePositions.ItemContainerGenerator.StatusChanged += ItemContainerGenerator_StatusChanged;
        }

void ItemContainerGenerator_StatusChanged(object sender, EventArgs e)
        {
            if (ListLinePositions.ItemContainerGenerator.Status == System.Windows.Controls.Primitives.GeneratorStatus.ContainersGenerated)
            {
                //...
                    foreach (LinePosition item in this.ListLinePositions.Items)
                    {
                          CheckBox cb = FindByName("checkedPosition",
                                                    (ListViewItem)this.ListLinePositions.ItemContainerGenerator.ContainerFromItem(item)) as CheckBox;    
                    }  
            }
        }

But this doesn’t work too.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T00:52:18+00:00Added an answer on June 9, 2026 at 12:52 am

    I find this and it works:

     //..
    CheckBox cb = FindByName("checkedPosition",
    (ListViewItem)this.ListLinePositions.ItemContainerGenerator.ContainerFromItem(item)) as CheckBox;
    
        if (cb == null)
        {
            this.ListLinePositions.ScrollIntoView(item);
            WaitFor(TimeSpan.Zero, DispatcherPriority.SystemIdle);
    
            cb = FindByName("checkedPosition",
                            (ListViewItem)this.ListLinePositions.ItemContainerGenerator.ContainerFromItem(item)) as CheckBox;
    
        }
    
     public static void WaitFor(TimeSpan time, DispatcherPriority priority)
            {
                DispatcherTimer timer = new DispatcherTimer(priority);
                timer.Tick += new EventHandler(OnDispatched);
                timer.Interval = time;
                DispatcherFrame dispatcherFrame = new DispatcherFrame(false);
                timer.Tag = dispatcherFrame;
                timer.Start();
                Dispatcher.PushFrame(dispatcherFrame);
            }
    
            public static void OnDispatched(object sender, EventArgs args)
            {
                DispatcherTimer timer = (DispatcherTimer)sender;
                timer.Tick -= new EventHandler(OnDispatched);
                timer.Stop();
                DispatcherFrame frame = (DispatcherFrame)timer.Tag;
                frame.Continue = false;
            }
    

    May be explain why does it work?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following WPF ListView: <ListView Grid.Column=2 Grid.Row=1 Margin=0,53,12,6 Name=lvwProperties ItemsSource={Binding Path=SelectedPropertyItems, Mode=TwoWay} Grid.ColumnSpan=2>
I have the following ListView : <ListView Name=listView1 Grid.Row=1 ItemsSource={Binding Items} > <ListView.ItemTemplate> <DataTemplate>
I have a Listview, such this: <ListView ItemsSource={Binding ...} > <ListView.ItemContainerStyle> <Style TargetType=ListViewItem> <Setter
the XAML of my window: <ListView Grid.Row=0 Name=files> <ListView.Resources> <DataTemplate x:Key=CheckboxTemplate> <CheckBox IsChecked={Binding Save,
Suppose we have this example: http://techdroid.kbeanie.com/2009/07/custom-listview-for-android.html with source code available here: http://code.google.com/p/myandroidwidgets/source/browse/trunk/Phonebook/src/com/abeanie/ How can
This code generates a Listview with a grid, of multiple name and emails inside
I have this very simple XAML window: <Grid> <Grid.RowDefinitions> <RowDefinition/> <RowDefinition/> </Grid.RowDefinitions> <ContentControl Content={Binding
This is the xaml of listview <ListView Grid.Column=1 Height=auto Name=ListView1 Width=auto AllowDrop =True >
I have an ASP.NET 2.0 ListView control (aka:parent) and configured inside this ListView I
I have this in res/values/styles.xml <style name=ListViewRowBorder > <item name=android:width>1dp</item> <item name=android:color>@color/listview_row_stroke_color</item> </style> I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.