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

The Archive Base Latest Questions

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

I have this case <WrapPanel> <CheckBox>Really long name</CheckBox> <CheckBox>Short</CheckBox> <CheckBox>Longer again</CheckBox> <CheckBox>Foo</CheckBox> <Slider MinWidth=200

  • 0

I have this case

<WrapPanel>
    <CheckBox>Really long name</CheckBox>
    <CheckBox>Short</CheckBox>
    <CheckBox>Longer again</CheckBox>
    <CheckBox>Foo</CheckBox>
    <Slider MinWidth="200" />
</WrapPanel>

I want all the CheckBoxes inside the WrapPanel to be the same width.

Adding the following almost accomplishes the desired effect

<WrapPanel.Resources>
    <Style TargetType="CheckBox" BasedOn="{StaticResource {x:Type CheckBox}}">
        <Setter Property="MinWidth" Value="75" />
    </Style>
</WrapPanel.Resources>

However, I do not want to hardcode a specific width, rather let the largest CheckBox set the width (the above also fails if any width > 75).

The Slider is independent and should be allowed to be larger than the CheckBoxes.

I do not want to use a Grid (with IsSharedSizeScope) since I do not want a hardcoded number of columns.

This article presents an interesting solution, but it would be nice to solve the problem without creating a custom control or using C# code.

What is the best way to do this, preferrably in XAML only?

  • 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-11T22:18:25+00:00Added an answer on May 11, 2026 at 10:18 pm

    I originally looked at this using IsSharedSizeGroup but hit a roadblock with making it dynamically apply to things instead of explicitly wrapping items. In this case, creating an AttachedProperty in code or another code based solution may in the long run be better then a XAML only approach. However, to create a purely XAML solution we can make use of the SharedSizeGroup property on a ColumnDefinition to share the sizes of each element and then use set the IsSharedSizeScope property on the WrapPanel. Doing so will make all of the contents in the WrapPanel with the same SharedSizeGroup share their width for columns and height for rows. To wrap the ComboBoxes and possibly ComboBoxes that are not currently in the XAML but will be added to the WrapPanel, we can create a Style and re-template the ComboBox to bassicly wrap it with a Grid.

    <WrapPanel Grid.IsSharedSizeScope="True">
      <WrapPanel.Resources>
        <Style TargetType="{x:Type CheckBox}">
          <Setter Property="Template">
            <Setter.Value>
              <ControlTemplate TargetType="{x:Type CheckBox}">
                <Grid Background="LightBlue">
                  <Grid.ColumnDefinitions>
                    <ColumnDefinition SharedSizeGroup="WrapPannelGroup" />
                  </Grid.ColumnDefinitions>
                  <CheckBox Style="{x:Null}"
                            IsChecked="{TemplateBinding IsChecked}">
                    <!--Other TemplateBindings-->
                    <CheckBox.Content>
                      <ContentPresenter />
                    </CheckBox.Content>
                  </CheckBox>
                </Grid>
              </ControlTemplate>
            </Setter.Value>
          </Setter>
        </Style>
    
      </WrapPanel.Resources>
      <CheckBox>Really long name</CheckBox>
      <CheckBox>Short</CheckBox>
      <CheckBox IsChecked="True">Longer again</CheckBox>
      <CheckBox>Foo</CheckBox>
      <Slider MinWidth="200" />
    </WrapPanel>
    

    Here we are re-templating all CheckBoxes without a style inside the WrapPannel to instead be CheckBoxes surrounded by a Grid. However, because of this we need to re-bind all of the CheckBoxes properties that we want to maintain. While that could become burdensome, it also allows for a pure XAML approach.

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

Sidebar

Related Questions

I have this: case true: echo '<textarea rows=2 cols=35 name=message_friend id=message_friend></textarea>'; break; default: echo
I have this use case of an xml file with input like Input: <abc
I have this test case def setUp(self): self.user = User.objects.create(username=tauri, password='gaul') def test_loginin_student_control_panel(self): c
Imagine this case where I have an object that I need to check a
I have this SQL query select case when AllowanceId is null then 2 else
i have this block of xslt if-else case and was wondering if there's a
I have an object (in this case a rating object from js-kit) that I
I Have two problem in this Case : I want to pass a JSON
i have this table in UTF8 (collation is utf8_bin in case it matters). I
So I have this problem with strings and switch-case, and I'll try to keep

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.