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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:31:03+00:00 2026-05-31T15:31:03+00:00

I need to create a custom control containing a combobox whose popup will have

  • 0

I need to create a custom control containing a combobox whose popup will have the Name propeprty of the bound objects aligned to the left, and the CreatedDate property of the bound objects aligned to the right in each pop up item. Also the Name and the CreatedDate must not overlap. The Name of the object is of variable length

I tried solving this problem using a DataTemplate in the Combobox.ItemTemplate, inside the data template I have a grid with two columns aligned appropriately. The Grid’s horizontal alignment is set to Stretch but for some reason the Grid doesn’t fill out the available space in the popup. Does anyone know how to get around this and why it happens? I am using WPF 3.5.

<UserControl.Resources>
    <CollectionViewSource x:Key="cvsProcessingSessionList" Source="{Binding ProcessingSessionList, ElementName=View}"/>
    <Style TargetType="{x:Type ComboBox}"
           BasedOn="{StaticResource {x:Static res:ObjectResources.LEComboBoxStyle}}">
        <Setter Property="Margin" Value="5,3"/>
        <Setter Property="HorizontalAlignment" Value="Stretch"/>
        <Setter Property="VerticalAlignment" Value="Center"/>            
    </Style>
</UserControl.Resources>

<GroupBox x:Name="grbProcessingSession">
    <GroupBox.Header>
        <Bold>Processing Session:</Bold>
    </GroupBox.Header>
    <GroupBox.Content>
        <ComboBox 
                  x:Name="ccbProcessingSessionName"
                  ItemsSource="{Binding Source={StaticResource cvsProcessingSessionList}}" 
                  Loaded="OnLoaded" TextSearch.TextPath="Name"
                  IsEditable="True" MaxDropDownHeight="500" >
            <ComboBox.ItemTemplate>
                <DataTemplate>
                    <Grid Background="Pink" HorizontalAlignment="Stretch" >
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="100" />
                        </Grid.ColumnDefinitions>

                        <TextBlock Grid.Column="0" TextAlignment="Left" HorizontalAlignment="Left" 
                                   Margin="0,0,5,0" Text="{Binding Name}"/>
                        <TextBlock  Grid.Column="1" TextAlignment="Right" HorizontalAlignment="Right" 
                                    Text="{Binding CreatedDate, StringFormat=dd/MM/yyyy}"/>
                    </Grid>
                </DataTemplate>
            </ComboBox.ItemTemplate>
        </ComboBox>
    </GroupBox.Content>
</GroupBox>

  • 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-31T15:31:04+00:00Added an answer on May 31, 2026 at 3:31 pm

    Just add this binding to your grid in yiour DataTemplate …

        Width="{Binding ActualWidth,
                        RelativeSource={RelativeSource FindAncestor,
                                AncestorType={x:Type ComboBoxItem}},
                        Mode=OneTime}"
    

    Also for better effect, apply the background color to the ComboBoxItem and not to the grid…

     <ComboBox.ItemContainerStyle>
          <Style TargetType="{x:Type ComboBoxItem}">
               <Setter Property="Background" Value="Pink"/>
          </Style>
     </ComboBox.ItemContainerStyle>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Need to create a custom DNS name server using C which will check against
I am learning JQuery. I have a need to create a custom control. This
I want to create custom control (let's name it DesignPanel ) that will allow
I'm trying to create a custom control by deriving from a ZedGraphControl I need
I'm trying to create a custom control and need to raise an event from
I need to create a custom TextBox control that allows user input HTML tags.
I need to create a dependency property on a custom control. The problem is
Windows Form (in C#) - I need to create a custom listbox control for
I need to create a custom security manager for a hosted WebBrowser control in
Hai Freinds So far i have used this coding to create a custom Control

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.