2012-01-12 45 views
0

我需要建立一個像一個組合框用戶控件。 在需要的項目中有一個TreeView和一個Button。 如果我導航樹,項目應該轉到底部的文本框。 如果我點擊按鈕樹應該摺疊。 我的第一個想法就是這樣,但它不好。 組合框蒙山一個TreeView

<StackPanel Orientation="Vertical"> 
     <StackPanel Orientation="Horizontal"> 
      <TextBox Text="{Binding Adresse, Mode=TwoWay}" MaxLength="50" MinWidth="170" Grid.Row="5" Margin="5,2,5,2"/> 
      <Button Width="25" Margin="2" Click="Down"> 
       <Image Source="/C1_net;component/Images/arrow.jpg" HorizontalAlignment="Left" /> 
      </Button>    

     </StackPanel> 
     <StackPanel x:Name="Tree" Orientation="Vertical" Visibility="Collapsed">     
      <sdk:TreeView Height="200" Name="treeView1" Width="200" /> 
      <Button Content="{Binding Path=ApplicationStrings.OKButton, Source={StaticResource ResourceWrapper}}" Width="75" Margin="5" Click="OnOk" HorizontalAlignment="Right"/> 

     </StackPanel> 

    </StackPanel> 

</Grid> 

如果我切換到可見的控制需要更大的空間。所以我需要把樹放在窗口的其他部分。 任何想法?

+2

這聽起來像是一個非常難使用的控制! – 2012-01-12 13:14:10

+0

使TreeView成爲一個單獨的頁面。你的問題不清楚。底部沒有文本框 - 只有頂部,爲什麼是底部資本。有兩個按鈕,但你只能參考1.如果你期望的幫助,你需要更多的努力到你的問題。 – Paparazzi 2012-01-12 14:25:06

+0

這種控制的用例是什麼?我認爲你應該重新審視你的互動。我不明白你爲什麼要設計這樣的表單控件。 – dex3703 2012-01-12 18:20:47

回答

0

確定。

我想你應該重新審視你的互動。

我有點難以思考如果我選擇我的項目,樹木被關閉。 我將在Hirarchical DataObjekt導航並把路徑作爲selectet項目。 所以我現在要這樣想:

public interface ITreeViewItemModel 
{ 
    string SelectedValuePath { get; } 

    bool IsExpanded { get; set; } 

    bool IsSelected { get; set; } 

    IEnumerable<ITreeViewItemModel> GetHierarchy(); 
    IEnumerable<string> GetDisplayHierarchy(); 
    IEnumerable<ITreeViewItemModel> GetChildren(); 
} 

和。

public class ComboBoxTreeView : ComboBox 
{ 
    private ExtendedTreeView _treeView; 
    private ContentPresenter _contentPresenter; 

    public ComboBoxTreeView() 
    { 
     this.DefaultStyleKey = typeof(ComboBoxTreeView); 
    } 

......

我發現這http://vortexwolf.wordpress.com/2011/04/29/silverlight-combobox-with-treeview-inside/