Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9112245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T03:41:21+00:00 2026-06-17T03:41:21+00:00

I’m beginner in programming in C# and WPF and I’m creating a file manager

  • 0

I’m beginner in programming in C# and WPF and I’m creating a file manager with 2 ListViews, all items bounded. In ListView there are some GridViewColumns and first has CellTemplate because I want there icon of file/folder and its name. The CellTemplate is:

<DataTemplate x:Key="IconTemplate">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="auto"/>
                    <ColumnDefinition/>
                </Grid.ColumnDefinitions>
                <Image Source="{Binding Path=itemIcon}" Width="20" Grid.Column="0"/>
                <TextBlock Grid.Column="1" Text="{Binding Path=itemName}" />
            </Grid>
        </DataTemplate>

And I had one Class : ObservableCollection where all directories and files are added to the collection and for every file its icon is converted from file. MyItem class contains few strings for name, extension etc. and one ImageSource for those icons. All worked well till i realised that some folders with different files freezes the program because of converting those icons. So now i bind some general icon for every file and then i want to convert and change it in another thread. So in main class i created global ObservableCollection for items and because i don’t know how to load them from the listView back i have moved the filling Collection function from Observable-class to the main class. Now I’m able to change items in listview from new thread but – finally here comes my problem – i get XamlParseException – Must create DependencySource on same Thread as the DependencyObject. When i tried to change file’s name (string) it worked perfectly (so far I’m testing it only on button click)! I tried to implement dependencyObject to MyItem class according to some reference i found on the internet but it didn’t worked. This changing icon function.

for (int i = leftDirectories.Length; i < (leftDirectories.Length + leftFiles.Length); i++)
        {
            FileToImageIconConverter some = new FileToImageIconConverter(locationLeft + leftFiles[i - leftDirectories.Length].Name);
            ImageSource imgSource = some.Icon;
            leftFilesLoad[i].itemIcon = imgSource;
            this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart)delegate()
                    {
                        contentLeft.Items.Refresh();
                    }
            );

Quite long article, stackoverflow says be specific :-D. Thank so much for everyone trying help me. I’m looking forward to your replies and I’m ready to show you all code you’ll need.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T03:41:23+00:00Added an answer on June 17, 2026 at 3:41 am

    The exception is occurring because you are creating the ImageSource on the none-UI thread. Unless you freeze the object, you cannot do this. You’re going to want all the UI related logic to included in your BeginInvoke call. Try this instead

    for (int i = leftDirectories.Length; i < (leftDirectories.Length + leftFiles.Length); i++)
    {
               this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart)delegate()
               {
                   FileToImageIconConverter some = new FileToImageIconConverter(locationLeft + leftFiles[i - leftDirectories.Length].Name);
                   ImageSource imgSource = some.Icon;
                   leftFilesLoad[i].itemIcon = imgSource;
                   contentLeft.Items.Refresh();
                }
        );
    }
    

    That should keep all UI related activity on the UI thread.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
I want use html5's new tag to play a wav file (currently only supported
In my XML file chapters tag has more chapter tag.i need to display chapters
I am trying to render a haml file in a javascript response like so:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.