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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:08:27+00:00 2026-05-18T10:08:27+00:00

I need to create two controls that contain the same amound of items (a

  • 0

I need to create two controls that contain the same amound of items (a dynamic amount), the first control represents the keys, the second represents the values.

I need it so that when the user resizes the upper column width it should affect the same column in the lower row (of the values).

Here is an example to what I desire:

<Window 
  DataContext="{Binding RelativeSource={RelativeSource Self}}"
  x:Class="MainWindow"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <Window.Resources>
    <ItemsPanelTemplate x:Key="ItemsPanelTemplate">
      <VirtualizingStackPanel Orientation="Horizontal"/>
    </ItemsPanelTemplate>
  </Window.Resources>
  <StackPanel>
    <ItemsControl ItemsSource="{Binding Keys}" 
                  ItemsPanel="{StaticResource ItemsPanelTemplate}"/>
    <ItemsControl Grid.Row="1" ItemsSource="{Binding Values}" 
                  ItemsPanel="{StaticResource ItemsPanelTemplate}"/>
  </StackPanel>
</Window>

Imports System.Collections.Specialized
Class MainWindow
  Private Sub Window_Loaded(ByVal sender As Object,
                            ByVal e As RoutedEventArgs) Handles MyBase.Loaded
    DataContext =
      New StringDictionary From
      {
        {"key1", "value1"},
        {"key2", "value2"},
        {"key3", "value3"},
        {"key4", "value4"}
      }
  End Sub
End Class

Result:

Again, I want to be able to create a DataGrid-like control that even supports cell borders and cell widths and heights should be connected to the other controls’ width + allow resize.

I prefer it to be done xamly.
Note: it’s a custom control, so I can declare appropriate properties if necessary. but remember the cells’ heights and width has to be dynamic and individual to specific columns/rows.

In reference to this question, I created it in a slightly different way (having a third control for cells), but the question is still the same, I want the height width of the columns and cells to be dynamic, and give the user ability to resize them affecting each other.

UPDATE

decyclone’s answer is something I would love to implement, but I tried the example he provided setting the ItemsControls’ Grid.IsSharedSizeScope property to true, but it didn’t work, here is the result (cropped):

Is it possible to apply a shared size scope between two different controls?

  • 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-18T10:08:28+00:00Added an answer on May 18, 2026 at 10:08 am

    I tried something and seems to work :

    XAML :

    <Window x:Class="WpfApplication2.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:local="clr-namespace:WpfApplication2"
            Title="MainWindow"
            Height="350"
            Width="525">
        <Window.Resources>
            <local:GroupNameGenerator x:Key="GroupNameGenerator1" />
            <local:GroupNameGenerator x:Key="GroupNameGenerator2" />
        </Window.Resources>
        <Grid>
            <StackPanel Grid.IsSharedSizeScope="True">
                <ItemsControl Name="ItemsControl1">
                    <ItemsControl.ItemsPanel>
                        <ItemsPanelTemplate>
                            <StackPanel Orientation="Horizontal" />
                        </ItemsPanelTemplate>
                    </ItemsControl.ItemsPanel>
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition SharedSizeGroup="{Binding Converter={StaticResource GroupNameGenerator1}}" />
                                </Grid.ColumnDefinitions>
                                <Border BorderBrush="Black"
                                        BorderThickness="1"
                                        Margin="5"
                                        Padding="5">
                                    <TextBlock Text="{Binding}" />
                                </Border>
                            </Grid>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>
                <ItemsControl Name="ItemsControl2">
                    <ItemsControl.ItemsPanel>
                        <ItemsPanelTemplate>
                            <StackPanel Orientation="Horizontal" />
                        </ItemsPanelTemplate>
                    </ItemsControl.ItemsPanel>
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition SharedSizeGroup="{Binding Converter={StaticResource GroupNameGenerator2}}" />
                                </Grid.ColumnDefinitions>
                                <Border BorderBrush="Black"
                                        BorderThickness="1"
                                        Margin="5"
                                        Padding="5">
                                    <TextBlock Text="{Binding}" />
                                </Border>
                            </Grid>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>
            </StackPanel>
        </Grid>
    </Window>
    

    Code :

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Navigation;
    using System.Windows.Shapes;
    using System.Collections.ObjectModel;
    
    namespace WpfApplication2
    {
        /// <summary>
        /// Interaction logic for MainWindow.xaml
        /// </summary>
        public partial class MainWindow : Window
        {
            ObservableCollection<Int32> list1 = new ObservableCollection<Int32>();
            ObservableCollection<String> list2 = new ObservableCollection<String>();
    
            public MainWindow()
            {
                InitializeComponent();
    
                for (int i = 0; i < 25; i++)
                {
                    list1.Add(i + 1);
                    list2.Add(new String('0', ((i + 1) / 3)));
                }
    
                ItemsControl1.ItemsSource = list1;
                ItemsControl2.ItemsSource = list2;
            }
        }
    
        public class GroupNameGenerator : IValueConverter
        {
            public Int32 Index { get; set; }
    
            public GroupNameGenerator()
            {
                Index = 0;
            }
    
            public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
            {
                return String.Format("Group{0}", ++Index);
            }
    
            public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
            {
                throw new NotImplementedException();
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have such task - to create control that union two controls (DataGrid from
If I want to do bi-directional mapping, do I need to create two mapping?
I have the following three arrays and need to create a new two-dimensional array
I need to create one list based on two other lists. But seems like
I need to create a class which calculates the distance between two points. I
I need to create a row in XAML which has a label,two radio buttons..
I have a Excel sheet with two columns and I need to create new
I need to create an extension of a Flex component, which (obviously) means that
I need to create an SSIS package that will do the following: Connect to
I'm experimenting with writing ActiveX controls and noticed that I can't seem to create

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.