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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:08:29+00:00 2026-06-13T07:08:29+00:00

I have a wpf TreeView with customized Items. Each node is a wpf Border

  • 0

I have a wpf TreeView with customized Items.
Each node is a wpf Border with a wpf expander inside. The expander contains the child items of the node, and so on. So every TreeViewNode has its items inside.

TreeViewItem: UI Representation:

the outer element: a wpf Border (the node): 

/-----------------\
|                 |
| title(textbox)  |
|                 |
|  \/Expander     |
|  |        |     |
|  | child  |     |
|  | items  |     |
|  ----------     |
|                 |
\-----------------/

The Viewmodel for the TreeViewItem has an ObservableCollection of further TreeviewItems.

If I add items using ObservableCollection<Item>.Add(..),
the TreeviewItem View shows the node with the new item: it enlarges the wpf Border and shows the new item inside the wpf Expander.

If I remove Items using ObservableCollectionyItem>.Remove(..), The Border shrinks again and shows an empty expander.

This is the behavior that I want to keep!

Problem: I used for the TextBox:

DockPanel.Dock = "Top" 

to fit to the Border width. This stretches the TextBox to fit the new border width.
When I remove a child Item, the border won’t get reduced in width, because the TextBox
is now larger. But I want the TextBoxto be independant from the outer border.

The TextBox should resize to the available space, when child items are added,
but should not influence the border from snapping back to a smaller size, when child items are removed.There should be no dependency from the TextBox width to any Layout elements.
How to achieve this?

example: If I use DockPanel.Dock="Left" for the textbox,
it will not grow (not good), but the border will snap back to its former size (good), when removing elements.

How can I make the width of the textbox not be relevant for the wpf automatic UI sizing ? By the way, I don’t want to size the treeviewitems from code.

  • 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-13T07:08:30+00:00Added an answer on June 13, 2026 at 7:08 am

    I found a very useful hint here:

    stackoverflow.com/questions/6338315/allow-wpf-grid-cell-content-to-expand-outside-of-the-grid-cell

    If you put the textbox inside a canvas, it won’t influence the outer border width!

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

Sidebar

Related Questions

I have WPF treeView which has ControlTemplate which show every node of treeView consisting
I have a WPF treeview used to display a file structure. Each treeitem has
I have a tree in WPF that has no root node, but has defined
Hey guys, I have a WPF TreeView that has three nodes, I would like
I have bound a WPF TreeView to an ObservableCollection. When a Connection node gets
I have a wpf application that displays a 'Node' as such: <TreeView HorizontalAlignment=Stretch Name=treeView1
I have a basic C# WPF TreeView, but I do not like that the
I have a treeview in wpf and I load it ok is all done
I have a hierarchical treeview in WPF. I use http://marlongrech.wordpress.com/2008/12/13/attachedcommandbehavior-v2-aka-acb/ for eventbinding with the
In WPF, I have a custom control that inherits from TreeView. The code is

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.