✅ File Searcher in Avalonia

Hey, I am just asking how to make a Open File Dialog so that it functions just like the one from Windows Forms, but how can I do that - I don´t want to make it so it only works on linux, I just wanna make it so it works on every big OS, but I just can´t find a way. Is there some kind of implemented way to do that or is there any tutorial on youtube or github? The thing is I wanna have a File Searcher where only specific Files are only listed if they have a specific extension.
15 Replies
Jimmacle
Jimmacle3d ago
there is https://docs.avaloniaui.net/docs/basics/user-interface/file-dialogs, i don't know exactly how it works on linux
Daiko Games
Daiko GamesOP3d ago
But this works just like the one from windows forms right?
FusedQyou
FusedQyou3d ago
It works like how folder and file pickers/savers work in general. It calls the native loader/saver
Daiko Games
Daiko GamesOP3d ago
ok, but is there a very simple way to make that like much simplier than that
FusedQyou
FusedQyou3d ago
I don't see how this is not already incredibly simple The only thing required is getting the top level so you have the storage provider
Daiko Games
Daiko GamesOP3d ago
I don´t understand the code nor how it works i went from windows Forms to Avalonia, I understand xaml but I don´t understand how this works
FusedQyou
FusedQyou3d ago
Unlike Winforms, Avalonia is cross platform. You sometimes need some extra steps here to get things working
Daiko Games
Daiko GamesOP3d ago
i know
FusedQyou
FusedQyou3d ago
In this case you need a top level, which is the root of your application Other than that I don't think it's much different to Windows
Daiko Games
Daiko GamesOP3d ago
so I need the Folderpath of my Application? that can´t be is it`?
FusedQyou
FusedQyou3d ago
That has nothing to do with it, I'm not sure what you are talking about
Daiko Games
Daiko GamesOP3d ago
oh, ok I misunderstood something ngl
FusedQyou
FusedQyou3d ago
https://github.com/AvaloniaUI/Avalonia/discussions/13599#discussioncomment-7562209 This is a very simple way to get the top level. Just define it in your app as a static variable depending on lifetime
GitHub
I am trying to get my toplevel for file dialog · AvaloniaUI Avaloni...
I am running var topLevel = TopLevel.GetTopLevel(this); in my mainviewmodel in order to open a save file dialog. However, I get this error: CS1503 Argument 1: cannot convert from 'xxxxxxxxxx.Vi...
FusedQyou
FusedQyou3d ago
It could be the Window or another visual depending on what the type of your application is, so therefore it's not explicitly defined I personally don't know if this could be any easier, but I know there are people in #gui with very good experience in this. You could possible ask them
Daiko Games
Daiko GamesOP3h ago
ok I will Well i think we can close it I found my own solution for it 🙂

Did you find this page helpful?