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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:19:40+00:00 2026-06-14T03:19:40+00:00

I have two controls in a Grid ,and need to make one to fill

  • 0

I have two controls in a Grid,and need to make one to fill all the Grid space after the another one get Collapseded,i don’t know what Container can i use,i tried StackPanel and DockPanel too,but i couldn’t find a good solution.here’s my code:

<Grid>
 <Grid.ColumnDefinitions>
    <ColumnDefinition Width="auto"/>
     <ColumnDefinition Width="auto"/>
 </Grid.ColumnDefinitions>
 <TextBox Grid.Column="0" Visibility="{Binding Istxt1Visible}"/>
 <TextBox Grid.Column="1" Visibility="{Binding Istxt2Visible}"/>
</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-06-14T03:19:41+00:00Added an answer on June 14, 2026 at 3:19 am

    what about using a converter? Such as

    in Window resources

    <Window.Resources>
        <local:VisibilityToColumnLengthConverter x:Key="visConv" />
    </Window.Resources>
    

    …..

    <Grid >
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="{Binding ElementName=tb1, Path=Visibility, Converter={StaticResource visConv}}"/>
                <ColumnDefinition Width="{Binding ElementName=tb2, Path=Visibility, Converter={StaticResource visConv}}"/>
            </Grid.ColumnDefinitions>
            <TextBox Grid.Column="0" Visibility="collapsed" Name="tb1" />
            <TextBox Grid.Column="1" Visibility="Visible"   Name="tb2" />
        </Grid>
    

    Finally the code of the converter is

    [ValueConversion(typeof(System.Windows.Visibility), typeof(System.Windows.GridLength))]
    public class VisibilityToColumnLengthConverter : IValueConverter
    {
        public object  Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            System.Windows.Visibility vis = (System.Windows.Visibility)value;
    
            if (vis == System.Windows.Visibility.Visible)
                return new System.Windows.GridLength(1, System.Windows.GridUnitType.Star);
            else
                return new System.Windows.GridLength(1, System.Windows.GridUnitType.Auto);
        }
    
        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 two controls on a page, one is a search entry and submission
I have two UIDatePicker controls in my app, one configured with UIDatePickerModeDate and one
I have two User Controls already created now I want to use one as
I have two user controls, in one of them I have a textbox, i
I have created two custom controls. On the basis of features any one of
I have a text box with event name and two calendar controls to get
I have two controls in a grid, an Ellipse and a Popup. The idea
I have a Telerik Grid, with two columns I need to keep second column
I have two different grid controls on the same form. They share the same
I have two controls whos code are run time rendered as below: ctl00_PlaceHolderMain_SPWebPartManager_g_3c1ba10a_23ec_4ab5_b303_18f8bd7ee7e7_ctl00_gdvItinerary_ctl03_txtTravelDate ctl00_PlaceHolderMain_SPWebPartManager_g_3c1ba10a_23ec_4ab5_b303_18f8bd7ee7e7_ctl00_gdvItinerary_ctl04_txtTravelDate

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.