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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:35:19+00:00 2026-06-17T11:35:19+00:00

I have a RadTreeView, in each item there is a RadCombobox with some elements.

  • 0

I have a RadTreeView, in each item there is a RadCombobox with some elements. Now I need to add some “special” item into each combobox. User can click on this item to add new element in combobox:
enter image description here

My current code:

<DataTemplate x:Key="Monitor">
        <Grid Height="Auto" Width="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="16" />
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <Image Grid.Column="0" Height="16" Width="16" Source="icons\monitor.png" />
            <TextBlock Text="{Binding Name}" Margin="5 0 0 0" Grid.Column="1" Width="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Center"/>

            <!-- PROBLEM IS HERE -->
            <telerik:RadComboBox Name="RadComboSchedule"
                 Grid.Column="2"
                 Margin="10 0 0 0"
                 Width="155"
                 ItemsSource="{Binding Source={StaticResource DataSource}, Path=ScheduleDataSource}"
                 ItemTemplate="{StaticResource ComboBoxTemplate}"
            >

            </telerik:RadComboBox>
            <Button Name="BtnRemoveMonitor" Grid.Column="3" Style="{StaticResource ButtonListBoxItemStyle}"  Template="{StaticResource RemoveButtonTemplate}" />
        </Grid>
    </DataTemplate>


<HierarchicalDataTemplate x:Key="Group"
           ItemTemplate="{StaticResource Monitor}"
           ItemsSource="{Binding Monitors}">
                <TextBlock Text="{Binding Name}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
</HierarchicalDataTemplate>


<telerik:RadTreeView
    Name="RadTreeViewGroups"
    Height="auto"
    Width="auto"
    ItemsSource="{Binding Source={StaticResource DataSource}, Path=GroupsDataSource}"
    ItemTemplate="{StaticResource Group}"
    >
</telerik:RadTreeView>

So, I have all like at a screenshot without element “Add new item”.
Any ideas?

PS It’s not a problem to use standard WPF Combobox and TreeView 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-06-17T11:35:20+00:00Added an answer on June 17, 2026 at 11:35 am

    You can create a new item in the DataSource of the ComboBox which name is “ADD NEW ITEM” and handle when the user select it.

    private void SelectItem(object sender, SelectionChangedEventArgs e)
    {
        if (e.AddedItems[0].ToString() == "new")
        {
            string newItem = "completely new item";
            dataSource.Add(newItem);
            ((ComboBox)sender).SelectedItem = newItem;
        }
    }
    

    In this question you can see a better example that each item is an instance of a class, so it’s easier to handle the “add item” request:
    Databound WPF ComboBox with 'New…' item


    Edit (about the ‘add item’ button template):
    Based on the example above

    Having this class

    public class DisplayClass
    {
        public string Name { get; set; }
        public bool IsDummy { get; set; }
    }
    

    You bind ComboBox.ItemsSource to an ObservableCollection like this one:

    public ObservableCollection<DisplayClass> DataSource { get; set; }
    

    Add that “dummy” item to the collection

    DataSource.Add(new DisplayClass { Name = "ADD ITEM", IsDummy = true });
    

    Then you handle the item selection with something like this:

    private void SelectItem(object sender, SelectionChangedEventArgs e)
    {
        var comboBox = (ComboBox)sender;
        var selectedItem = comboBox.SelectedItem as DisplayClass;
    
        if (selectedItem != null && selectedItem.IsDummy)
        {
            //Creating the new item
            var newItem = new DisplayClass { Name = comboBox.Items.Count.ToString(), IsDummy = false };
            //Adding to the datasource
            DataSource.Add(newItem);
    
            //Removing and adding the dummy item from the collection, thus it is always the last on the 'list'
            DataSource.Remove(selectedItem);
            DataSource.Add(selectedItem);
    
            //Select the new item
            comboBox.SelectedItem = newItem;
        }
    }
    

    To display the items properly, you’ll need to change the ComboBox.ItemTemplate, making the image invisible when the item is dummy

    <ComboBox ItemsSource="{Binding DataSource}" SelectionChanged="SelectItem">
        <ComboBox.ItemTemplate>
            <DataTemplate>
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="{Binding Name}" Width="180" />
                    <Image HorizontalAlignment="Right" Source="..." MouseLeftButtonUp="DeleteItem">
                        <Image.Style>
                            <Style TargetType="Image">
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding IsDummy}" Value="True">
                                        <Setter Property="Visibility" Value="Hidden" />
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </Image.Style>
                    </Image>
                </StackPanel>
            </DataTemplate>
        </ComboBox.ItemTemplate>
    </ComboBox>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using a RadTreeView to display some data and I need to be able
I have a RadTreeView C# component. The tree is nested, so some Nodes have
I currently have a page that contains a RadTreeView. On each node of the
I have a Radtreeview that sits inside a RadGrid. For some reason the expand/collapse
Have got a method which returns IEnumerable<User> which I have been using Linq /
Have been trying to figure this problem out for a while now and was
have numerous tests working, but my actual test of some objects is failing and
Have run into a bug with glibc's malloc(): http://sourceware.org/bugzilla/show_bug.cgi?id=4349 and am thinking a work
Have a linking (or ref) table which has a dual primary key. Need to
I have a RadTreeView with a custom NodeTemplate. Inside that node template, I have

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.