views:

141

answers:

2

I am trying to create a drop down control that is made up of a text box a button and a treeview control. I can not really find any tutorials on how to create a custom drop down control. I did find a user control that drops down a treeview control (vectorlight), but I want to implement my own custom drop down control. Any help would be greatly appreciated.

+1  A: 

The answer is to use a popup control like so

  <Popup Name="popupTask" IsOpen="False">
    <Border BorderThickness=".5" CornerRadius="5" BorderBrush="Black" Background="White">
      <sdk:TreeView Grid.Row="1" Height="300" Width="270" Name="treeViewTasks" VerticalAlignment="Top"  SelectedItemChanged="treeViewTasks_SelectedItemChanged" />
    </Border>
  </Popup>

From the code behind if (popupTask.IsOpen) { popupTask.IsOpen = false; } else { popupTask.VerticalOffset = 25; popupTask.HorizontalOffset = 0; popupTask.IsOpen = true; }

John Soer
A: 

I suggest you have a look at this open source control:

http://sl4popupmenu.codeplex.com

Its quite flexible and easy to implement and supports any derivative of the ItemsControl which includes the TreeView.

Ziad