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 9251753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:46:48+00:00 2026-06-18T10:46:48+00:00

I have an array (stored as an ObservableCollection ) of data that I am

  • 0

I have an array (stored as an ObservableCollection) of data that I am dynamically instantiating, and I am linking it to an ItemsControl within a StackPanel. The data is formatted like so:

public class VariableValueList<T>
{
    public String Name {get; private set;}
    public IList<T> Values {get; private set;}
    ...
}

and my ObservableCollection<VariableValueList<double>> IVCollection, after constructed, is linked to ItemsControl with the following:

MainWindow.xaml.cs

private void Open_OnClick(object sender, RoutedEventArgs e)
{
    ...
    IndependentVariables.ItemsSource = IVCollection;
}

where IndependentVariables originates here:

MainWindow.xaml

        <StackPanel>
            <ItemsControl Name="IndependentVariables" Style="{StaticResource IVCell}"></ItemsControl>
        </StackPanel>

I need to construct Style IVCell to have access to each VariableValueList<double> (once I get that, it will be trivial to obtain its Name and Values members).

I need the data to be formatted so that, for each element, Name and Values are printed, like so:

Name

Value Value Value …

Name

Value Value Value …

…

taking advantage of the existing StackPanel. I understand that there are at least two underlying questions in this problem.

  1. How do I give a Style access to this array? (or: How do I modify a Style after I have the array?)

  2. How do I instantiate new elements within a Style on the fly (e.g. for each array element)?

I really appreciate your help. If I’m trying to structure anything in this way completely wrong, please correct me. I am fairly new to WPF.

  • 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-18T10:46:49+00:00Added an answer on June 18, 2026 at 10:46 am

    You don’t need that extra StackPanel, because ItemsControl will create it’s own panel for items.
    Style doesn’t need access to array, ItemsControl creates and manages containers for all items automatically. All you need is to provide DataTemplate for both types of items. You can use another ItemsControl inside DataTemplate for VariableValueList<double> to display items contained in Values property. To get horizontal layout, set custom ItemsPanelTemplate for that ItemsControl.

    Simple style to start with:

    <Style TargetType="{x:Type ItemsControl}"
           x:Key="IVCell">
        <Setter Property="ItemTemplate">
            <Setter.Value>
                <DataTemplate>
                    <StackPanel>
                        <TextBlock Text="{Binding Name}" />
                        <ItemsControl ItemsSource="{Binding Values}">
                            <ItemsControl.ItemsPanel>
                                <ItemsPanelTemplate>
                                    <WrapPanel />
                                    <!-- or <StackPanel Orientation="Horizontal"> -->
                                </ItemsPanelTemplate>
                            </ItemsControl.ItemsPanel>
                            <ItemsControl.ItemTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding}" Margin="2,0" />
                                </DataTemplate>
                            </ItemsControl.ItemTemplate>
                        </ItemsControl>
                    </StackPanel>
                </DataTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an array that's stored like this: [0] => Array ( [id] =>
I have a tableview that displays data from an array stored in a NSObject.
I have an array stored in a variable temp which looks like this: temp.inspect
I have a multi-array stored in a SESSION I loop through the data in
I have an array of vectors that I want to be stored in Block
I have an array of floats where data are stored with varying decimal points
If I have an array declared like this: int a[3][2]; stored at address A
I have an array that looks like this: Array ( [0] => Array (
So in javascript I have an array that looks about like this: [{x1:0,x2:2000,y:300},{x1:50,x2:250,y:500}] And
I would like to read in an Array I have stored in a PLIST,

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.