Skip to content

FileDialog in OpenMode Directory #4095

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
powertec-dan opened this issue May 21, 2025 · 5 comments
Closed

FileDialog in OpenMode Directory #4095

powertec-dan opened this issue May 21, 2025 · 5 comments
Labels

Comments

@powertec-dan
Copy link

powertec-dan commented May 21, 2025

I'm using Version="2.0.0-prealpha.1895"

I construct a FileDialog view as follows:

`

var dlg = new FileDialog()
{
Path = Environment.CurrentDirectory,
OpenMode = OpenMode.Directory,
AllowsMultipleSelection = false,
MustExist = true,
Title = "Select location to store backups",
};
Application.Run(dlg, ErrorHandler);
bool canceled = dlg.Canceled;
var folderName = dlg.Path;
dlg.Dispose();
`

When I run the app and open the dialog.
When hitting the "Up" button, the dialog closes and the dlg.Path is filled with the upper path. I don't want the dialog to close in this case. Is that possible?
When hitting the cancel button, the dialog is closed, but dlg.Canceled is set to false; This just seems wrong.

Is there something I haven't set? There doesn't appear to be any obvious properties to avoid these situations.

Also, in the same application I use a FileDialog to select files, and in that case, the dialog behaves as expected so it seems like it is only in OpenMode.DIrectory where these things occur.

This app is cross compiled onto Windows, Linux 64bit and Linux Arm 32 and 64 bit. The behaviour is consistent across all OSs

Again, if I am doing something wrong, please let me know.

Cheers,
Dan

@tznind
Copy link
Collaborator

tznind commented May 21, 2025

You are using 2 month old nuget package. Try switching to one of these more recent ones.

Nuget.org shows this old package as 'latest' despite it being very old because of the naming. It's a recurring problem see also:

The bug you seeing was

Was fixed in

Screenshot_20250521_040157_Firefox Focus.jpg

@powertec-dan
Copy link
Author

Ok thank you,

I've updated to Version="2.0.0-develop.4425" and it has cured the "Up" button closing the FileDialog.

But it has been replaced with an effect where "Accepting" on a Button is called 3 times.
Should I be using a different event on a normal button for its action?

@tznind
Copy link
Collaborator

tznind commented May 21, 2025

So currently any event handler for Accepting needs e.Handled=true

Please try adding this to all button event handlers. If you already have it can you share more info about what button is affected.

Note it might be called e.Cancel depending on your exact nuget version.

@powertec-dan
Copy link
Author

Brilliant, thank you.

It seems I had a variety of handlers, some of which set the e.Handled and some of which didn't. They are all consistent now and the app works properly.

Thank you very much for the support.

@tig
Copy link
Collaborator

tig commented May 21, 2025

Actually, 2.0.0-prealpha.1895 is the very latest pre-alpha.

However, it is old. I'm waiting for #4062 before i do another pre-alpha release given the amount of churn in that PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants