C# WPF UI Tutorials: 02 - TreeViews and Value Converters

AngelSix · 349K views · 2017 · 1:15:55

Open on YouTube

Software practice, open source & careersTesting, debugging & developer toolstutorial

Why Stack Overflow recommends it

Stack Overflow users link it when answering or asking about building a file-system TreeView in WPF, and many questioners say they are following it step by step when icons or the designer break.

Recommended by 1 people across 1 different months, 2017 to 2022.

What it is

A 75-minute C# WPF tutorial by AngelSix, part two of a series on building desktop apps. It builds a TreeView that mimics File Explorer and uses a value converter to turn file and folder paths into the right icons.

What people said

Recommends Mr. Leeds · 2018-06 · Stack Overflow · on “How do I customize the FileOpen dialog for >= Vista?”

This guy created a treeview directory. [this video] It can give you some hints to create your own OpenFileDialog.

Cites vinit · 2017-12 · Stack Overflow · on “Value converter not loading images in Tree View”

I'm a beginner at C#. Trying to follow this tutorial : [this video] I've currently created a TreeView to display all the folders/files in the system as described in the above video. I've added a valueConverter class to change the icon based on if the item is a drive/folder/file. Have three files for that accordingly. Now, the problem, I'm facing is that, when I run the program, there's no exception thrown, but the images are not displayed. If I add a static image file in the corresponding xaml file, I see that it's displayed. But if I used a valueConverter, it's not. I single stepped into the program, and I can see that my valueConverter function is being successfully called and the corresponding

Cites panup · 2019-02 · Stack Overflow · on “Visual Studio 2017 Designer 'Invalid Markup' error although code works”

I copied a project made in this Youtube video: [this video] However, the designer shows "Invalid Markup" although the code works perfectly and building is successful. (The guy in Youtube-video encounters same problem (in 59:43-59:56), but solves it somehow. I have still the same problem.) The XAML gives a blue underline under: Source="{Binding, which shows error: The name "HeaderToImageConverter" does not exist in the namespace "clr-namespace:WpfTreeView". The program still runs fine, I just don't see the designer. I have tried to tackle this problem by trying the following things: Configurate between Debug/Release and x64/x84 platforms Delete .bin .obj and .vs folders Delete ShadowCache folder C

Cites PMJ · 2022-04 · Stack Overflow · on “WPF application is unable to show the image”

I am new to WPF and is going thru a tutorial. [this video] I follow exactly the same steps, but images are not loaded in my application. What I am doing wrong? Note : Folder contains the said image. When I run the application, it only shows text "Some folder" but not the icon ( where as the same coding in the tutorial shows the image ). <Window x:Class="WpfTreeView.MainWindow" Loaded="Window_Loaded" Title="MainWindow" Height="450" Width="800"> <Grid> <TreeView x:Name="FolderView"> <TreeView.Resources> <Style TargetType="{x:Type TreeViewItem}"> <Setter Property="HeaderTemplate"> <Setter.Value> <DataTemplate> <StackPanel Orientation="Vertical"> <Image Width="20" Margin ="3" Source="Images/drive.png