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

  • SEARCH
  • Home
  • 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 3604606
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T21:01:11+00:00 2026-05-18T21:01:11+00:00

I am trying to access a Grid inside the DataTemplate while the ItemsControl is

  • 0

I am trying to access a Grid inside the DataTemplate while the ItemsControl is binded by ItemsSource.

this is the full XMAL code, How do i find a certain element from outside?

for (int i = 0; i < allViewControl.Items.Count; i++)
{
 var container =  allViewControl.ItemContainerGenerator.ContainerFromItem(allViewControl.Items[i]) as FrameworkElement;
 var grid = allViewControl.ItemTemplate.FindName("grid", container) as DataGrid;
}

i found this always returning null ?

<ScrollViewer Grid.Row="0" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
    <ItemsControl  x:Name="allViewControl" Focusable="False" HorizontalContentAlignment="Center"
     Grid.IsSharedSizeScope="true" ItemsSource="{Binding AllClassCharacters}" 
     ItemTemplate="{StaticResource CharacterViewModelTemplate}"  >
        <ItemsControl.ItemsPanel>
            <ItemsPanelTemplate>
                <Extensions:AnimatedWrapPanel  IsItemsHost="true" />
            </ItemsPanelTemplate>
        </ItemsControl.ItemsPanel>
    </ItemsControl>
</ScrollViewer>



 <DataTemplate x:Key="CharacterViewModelTemplate" DataType="{x:Type ViewModel:CharacterViewModel}">
            <Grid x:Name="grid" Width="200" Height="Auto" MinHeight="115" Margin="1" MinWidth="130" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" RenderTransformOrigin="0.5,0.5" Background="#66000000"     >
                <Grid.RowDefinitions>
                    <RowDefinition Height="70"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
            <ProgressBar x:Name="playerProgressBar" VerticalAlignment="Top" Background="Transparent" Height="5" Width="Auto" Value="0" Visibility="Collapsed" Grid.Column="0" Grid.Row="0" Grid.ColumnSpan ="2" Grid.RowSpan="2" Foreground="White" BorderThickness="0" Style="{DynamicResource ProgressBarStyle1}" />
</Grid>
  • 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-05-18T21:01:12+00:00Added an answer on May 18, 2026 at 9:01 pm

    Short answer is that you shouldn’t need to do this – using MVVM should give you simpler solutions to whatever you’re trying to achieve.

    If you need it for some niche cases like setting the focus, search for ‘find control wpf’ on so – there are some existing questions (example) to hack and get controls out of the WPF UI Tree

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

Sidebar

Related Questions

i am trying to access a named grid inside a default template for a
I'm trying to access datasource before I bind it to grid. How do I
I am trying to access a view inside a splitter from my mainframe. At
This problem involved me not knowing enough of C++. I am trying to access
I am trying to get access to a named TextBox (textBoxAnswer) in the code
I'm trying to implement pinch/stretch zooming on a ListBox: <ListBox Grid.Row=1 ManipulationCompleted=ListBox_ManipulationCompleted ItemsSource={Binding Paras}>
I am trying to access an element which is inside of a frame but
Im trying to access a web service from a remote computer. I managed to
Im trying to access the Magento customer session in another part of my website.
Im trying to access a Sql CE 2005 database on a windows mobile device

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.