Darren Ng
Darren Ng

Reputation: 373

Moving a TabControl

I need to move a TabControl dynamically in code. How do I do it?

I tried setting the margin, wrapping it in a scatterviewitem (using Center, but it always returns 0,0 ), wrapping it in a canvas (in hope of using .Left and .Top) but they all didn't work. Can someone point me in the right direction?

Upvotes: 0

Views: 136

Answers (1)

Jawahar
Jawahar

Reputation: 4885

Moving a control in WPF visually is based on the panel you used. For example, you have to adjust rows and columns if you use Grid and Top, Left properties if you used Canvas.

But a good approach is to use transformations. Use TranslateTransform to move your elements. Since transformation will not affect the layout pass.

   <TabControl >
       <TabControl.RenderTransform>
           <TranslateTransform x:Name="translation"/>
       </TabControl.RenderTransform>
   </TabControl>

Adjust X and Y values in code,

translation.X = 200;

Upvotes: 1

Related Questions