You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Create a file picker
var openPicker = new Windows.Storage.Pickers.FileOpenPicker();
// Retrieve the window handle (HWND) of the current WinUI 3 window.
var window = WindowHelper.GetWindowForElement(this);
var hWnd = WinRT.Interop.WindowNative.GetWindowHandle(window);
// Initialize the file picker with the window handle (HWND).
WinRT.Interop.InitializeWithWindow.Initialize(openPicker, hWnd);
// Set options for your file picker
openPicker.ViewMode = PickerViewMode.Thumbnail;
openPicker.FileTypeFilter.Add("*");
// Open the picker for the user to pick a file
var file = await openPicker.PickSingleFileAsync();
if (file != null)
{
PickAFileOutputTextBlock.Text = "Picked file: " + file.Name;
}
else
{
PickAFileOutputTextBlock.Text = "Operation cancelled.";
}
Error:
System.NullReferenceException
HResult=0x80004003
Message=Object reference not set to an instance of an object.
Source=Microsoft.Windows.SDK.NET
StackTrace:
at WinRT.Interop.IWindowNativeMethods.get_WindowHandle(Object _obj)
at WinRT.Interop.WindowNative.GetWindowHandle(Object target)
at Orchid.Views.HomePage.<OpenFile_Click>d__4.MoveNext()
What are the step to handle File Picker?
To Reproduce
No response
Additional context
No response
Applies to the following platforms:
WinUI
WPF
UWP
About your setup
No response
The text was updated successfully, but these errors were encountered:
Abhi-95
added
the
bug
The issue relates to the wizard not working or a problem with the generated code.
label
Aug 25, 2023
Describe the bug
Code : https://github.com/microsoft/WinUI-Gallery/blob/main/WinUIGallery/ControlPages/FilePickerPage.xaml.cs
// Create a file picker
var openPicker = new Windows.Storage.Pickers.FileOpenPicker();
// Retrieve the window handle (HWND) of the current WinUI 3 window.
var window = WindowHelper.GetWindowForElement(this);
var hWnd = WinRT.Interop.WindowNative.GetWindowHandle(window);
// Initialize the file picker with the window handle (HWND).
WinRT.Interop.InitializeWithWindow.Initialize(openPicker, hWnd);
// Set options for your file picker
openPicker.ViewMode = PickerViewMode.Thumbnail;
openPicker.FileTypeFilter.Add("*");
// Open the picker for the user to pick a file
var file = await openPicker.PickSingleFileAsync();
if (file != null)
{
PickAFileOutputTextBlock.Text = "Picked file: " + file.Name;
}
else
{
PickAFileOutputTextBlock.Text = "Operation cancelled.";
}
Error:
System.NullReferenceException
HResult=0x80004003
Message=Object reference not set to an instance of an object.
Source=Microsoft.Windows.SDK.NET
StackTrace:
at WinRT.Interop.IWindowNativeMethods.get_WindowHandle(Object _obj)
at WinRT.Interop.WindowNative.GetWindowHandle(Object target)
at Orchid.Views.HomePage.<OpenFile_Click>d__4.MoveNext()
What are the step to handle File Picker?
To Reproduce
No response
Additional context
No response
Applies to the following platforms:
About your setup
No response
The text was updated successfully, but these errors were encountered: