none
TabControl.ContentTemplate绑定集合不显示,单独抽listview又可以显示 RRS feed

全部回复

  • Hi,

    我看了你的代码,你在TabControl跟ListView绑定了两遍TfMkMeterRecordCollection,我觉得这样写是有问题的,正常都是将ListView里面需要集合放在TabControl的集合里面,看我的例子:

      public partial class MainWindow : Window
        {
            ObservableCollection<TabDe> informationList;
            public MainWindow()
            {
                InitializeComponent();
                informationList = new ObservableCollection<TabDe>();
                informationList.Add(new TabDe("Name1", new List<FilesFolder>() { new FilesFolder() { ffName = "ffName1" } }));
                informationList.Add(new TabDe("Name2", new List<FilesFolder>() { new FilesFolder() { ffName = "ffName2" } }));
                informationList.Add(new TabDe("Name3", new List<FilesFolder>() { new FilesFolder() { ffName = "ffName3" } }));
                informationList.Add(new TabDe("Name4", new List<FilesFolder>() { new FilesFolder() { ffName = "ffName4" } }));
                Actions.ItemsSource = informationList;
    
            }
        }
    
        public class TabDe
        {
           public TabDe(string inFolderName, List<FilesFolder> inFilesFolders)
            {
                folderName = inFolderName;
                FF = inFilesFolders;
            }
    
            public string folderName { get; set; }
            
            private List<FilesFolder> _FF = new List<FilesFolder>();
            public List<FilesFolder> FF
            {
                get { return _FF; }
                set { _FF = value; }
            }
        }
    
        public class FilesFolder
        {
            public string ffName { get; set; }
        }
      <TabControl   Name="Actions" >
                <TabControl.ItemTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding folderName}" />
                    </DataTemplate>
                </TabControl.ItemTemplate>
                <TabControl.ContentTemplate>
                    <DataTemplate>
                        <ListBox ItemsSource="{Binding FF}">
                            <ListBox.ItemTemplate>
                                <DataTemplate>
                                    <StackPanel Orientation="Horizontal">
                                        <TextBox Text="{Binding ffName}"  />
                                    </StackPanel>
                                </DataTemplate>
                            </ListBox.ItemTemplate>
                        </ListBox>
                    </DataTemplate>
                </TabControl.ContentTemplate>
            </TabControl>

    Best Regards,

    Alex

    如果您对Visual Studio 或Microsoft Azure相关产品感兴趣,请点击此链接,或扫描以下二维码注册获取相关信息。


    2020年3月18日 9:18