Articles → WPF → Visual Tree And Logical TreeVisual Tree And Logical TreeIn this tutorial we will discuss logical tree and visual tree. If you are working in WPF then you must know the difference between the two.To illustrate the concept I am using a simple example in which I have a grid and inside the grid we have a button<Grid><Button>Click</Button></Grid>In the example above Grid is the visual parent of button.Now let us consider another example.<Grid><Button><StackPanel><Image /><TextBlock>Clack</TextBlock></StackPanel></Button></Grid>In the above example logical parent of is ContentPresenter.To understand this you should know how button is actually rendered in wpf.Click to EnlargeAs you can see in the figure above Button is actually rendered as content presenter. So the logical parent of StackPanel is ContentPresenter.Posted By - Karan Gupta Posted On - Wednesday, December 15, 2010 Query/Feedback Your Email Id** Subject* Query/Feedback Characters remaining 250**
<Grid><Button>Click</Button></Grid>
<Grid><Button><StackPanel><Image /><TextBlock>Clack</TextBlock></StackPanel></Button></Grid>
Query/Feedback