C# 在tabcontrol标题内的弹出窗口中绑定列表框
我正在选项卡标题中创建一个弹出窗口,我想将列表绑定到弹出窗口中的列表框。但绑定不起作用。此弹出窗口位于选项卡控件的控件模板内C# 在tabcontrol标题内的弹出窗口中绑定列表框,c#,wpf,wpf-controls,C#,Wpf,Wpf Controls,我正在选项卡标题中创建一个弹出窗口,我想将列表绑定到弹出窗口中的列表框。但绑定不起作用。此弹出窗口位于选项卡控件的控件模板内 这是我需要装订的清单 publicobservableCollection选项卡项{get;set;}= 新的可观察集合(); 您可以将弹出窗口的标记属性绑定到定义源属性的父控件,然后将列表框绑定到父弹出窗口的标记属性: <Popup PlacementTarget="{Binding ElementName=ConnectionListDropDow
这是我需要装订的清单
publicobservableCollection选项卡项{get;set;}=
新的可观察集合();
您可以将弹出窗口的标记
属性绑定到定义源属性的父控件,然后将列表框
绑定到父弹出窗口的标记
属性:
<Popup PlacementTarget="{Binding ElementName=ConnectionListDropDownButton}"
IsOpen="{Binding ElementName=ConnectionListDropDownButton, Path=IsChecked}"
AllowsTransparency="True"
PopupAnimation="Slide"
StaysOpen="False"
Tag="{Binding RelativeSource={RelativeSource AncestorType=UserControl}}">
<Grid>
<ListBox Name="ConnectionList"
ItemsSource="{Binding Tag.tabItems, RelativeSource={RelativeSource AncestorType=Popup}}"
Background="White" SelectionChanged="ConnectionList_SelectionChanged" MaxHeight="300" BorderBrush="LightGray" BorderThickness="1" SelectionMode="Single" SelectedIndex="-1">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Header}"></TextBlock>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</Popup>
您不能使用相对资源
从弹出窗口将直接绑定到父控件,并且选项卡项
在哪里定义?绑定有什么不起作用?行为如何?@mm8选项卡项在包含tabcontrol@PeterBoonetabitems包含元素,但listbox不显示任何内容。