第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

使用 Galasoft MVVM 無法顯示 TreeView 項目

使用 Galasoft MVVM 無法顯示 TreeView 項目

C#
開心每一天1111 2021-06-03 18:51:08
我在使用 WPF 和 Galasoft MVVM 工具包獲得一個簡單的 TreeView 來顯示項目時遇到了一些困難。我一定錯過了一些簡單的東西,但我就是找不到。目前我想要的只是創(chuàng)建一組幾個節(jié)點并顯示它們。我什至還沒有編寫任何 RelayCommands 或任何其他實質(zhì)性內(nèi)容,因此無需擔(dān)心。另外,我認識到我可能需要在某處包含一個 HierarchicalDataTemplate - 大概是替換“TreeView.ItemTemplate”部分。誰能指出我看不到的明顯錯誤?任何幫助將不勝感激!編輯:我已經(jīng)更新了代碼來修復(fù)我愚蠢的缺乏子節(jié)點列表的問題,但仍然沒有顯示任何內(nèi)容。主窗口.xaml:<Window x:Class="Analyzer.MainWindow"        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"        xmlns:ignore="http://www.galasoft.ch/ignore"        mc:Ignorable="d ignore"        Height="495.333"        Width="700"        Title="Analyzer"        DataContext="{Binding MainViewModel, Source={StaticResource Locator}}">    <Window.Resources>        <ResourceDictionary>            <ResourceDictionary.MergedDictionaries>                <ResourceDictionary Source="Skins/MainSkin.xaml" />            </ResourceDictionary.MergedDictionaries>        </ResourceDictionary>    </Window.Resources>    <Grid x:Name="LayoutRoot" Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}">        <TextBlock FontSize="36"                   FontWeight="Bold"                   Foreground="Purple"                   VerticalAlignment="Center"                   HorizontalAlignment="Center"                   TextWrapping="Wrap" />        <TreeView ItemsSource="{Binding AllItems}" x:Name="MainTreeView" HorizontalAlignment="Left" Height="408" Margin="10,10,0,0" VerticalAlignment="Top" Width="662">            <TreeView.ItemTemplate>                <HierarchicalDataTemplate ItemsSource="{Binding Children}">                    <StackPanel Orientation="Horizontal">                        <TextBlock Text="{Binding Path=Name}" />                    </StackPanel>                </HierarchicalDataTemplate>            </TreeView.ItemTemplate>        </TreeView>
查看完整描述

2 回答

?
手掌心

TA貢獻1942條經(jīng)驗 獲得超3個贊

我認為你是對的,這兩者之一存在問題;我一定在編輯過程中覆蓋或剝離了一些重要的東西。我發(fā)現(xiàn)創(chuàng)建一個新項目后,我在理順事情方面遇到的問題要少得多。


我還必須對我的 XAML 代碼進行以下更改:


<TreeView x:Name="treeView" ItemsSource="{Binding AllItems.Children}" HorizontalAlignment="Left" Height="100" Margin="10,10,0,0" VerticalAlignment="Top" Width="188">

            <TreeView.ItemTemplate>

                <HierarchicalDataTemplate ItemsSource="{Binding Children}">

                    <TextBlock Text="{Binding Name}"/>

                </HierarchicalDataTemplate>

            </TreeView.ItemTemplate>

        </TreeView>

出于某種原因,我無法將其直接綁定到 AllItems - 我必須將頂級綁定到子項。這省略了我的根節(jié)點,但其他一切似乎都有效,所以我現(xiàn)在就用這個。謝謝您的幫助!


查看完整回答
反對 回復(fù) 2021-06-05
  • 2 回答
  • 0 關(guān)注
  • 228 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號