0
我想在同一TreeViewItemContainer中基於ComboBox
的SelectedItem綁定TextBox
的可見性。我想我可以使用轉換器進行綁定,但我不知道如何發送ComboBox
項目作爲TextBox
綁定的參數。這可以做到嗎?如何通過綁定轉換器引用TreeViewItem中的另一個控件?
<TreeView>
<TreeView.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<ComboBox Margin="2,0" Name="SkillSelectCB" ItemsSource="{Binding PotentialChildren}" />
<TextBox Margin="2,0" Width="50" Visibility="{Binding ??}" />
<Button Margin="2,0" Content="Add" />
</StackPanel>
</DataTemplate>
</TreeView.ItemTemplate>
</TreeView>
這實際上是在HierarchicalDataTemplate,上面的例子中是很小的。根據ComboBox
中選擇的內容,「Add」Button
將爲TreeView
的ViewModel添加新的子項。可見性是TextBox
將根據ComboBox
的SelectedItem的某些屬性而變化。
那你試試?你應該發佈你的代碼... – makc 2013-02-28 08:39:19
@makc我不知道該怎麼嘗試。我認爲這可以用轉換器完成,但我似乎無法在任何地方找到示例。如果有幫助,我已將Xaml包含在「TreeView」中。 – 2013-02-28 16:11:31
@makc啊,沒關係我知道了,這比我想象的容易,昨晚我一定累得太累了。 – 2013-02-28 16:29:43