Comments (1)
Everything is all right If you use this:
private async void OpenButton_Click(object sender, RoutedEventArgs e)
{
//https://github.com/microsoft/WindowsAppSDK/issues/1188
//More info on obtaining the HWND
var filePicker = new FileOpenPicker();
// Get the current window's HWND by passing in the Window object
var hwnd = WinRT.Interop.WindowNative.GetWindowHandle(this);
// Associate the HWND with the file picker
WinRT.Interop.InitializeWithWindow.Initialize(filePicker, hwnd);
// Use file picker like normal!
filePicker.FileTypeFilter.Add("*");
var file = await filePicker.PickSingleFileAsync();
if (file != null)
{
using (Windows.Storage.Streams.IRandomAccessStream randAccStream =
await file.OpenAsync(Windows.Storage.FileAccessMode.Read))
{
// Load the file into the Document property of the RichEditBox.
editor.Document.LoadFromStream(Microsoft.UI.Text.TextSetOptions.FormatRtf, randAccStream);
}
}
}
instead of this:
private async void OpenButton_Click(object sender, RoutedEventArgs e)
{
//https://github.com/microsoft/WindowsAppSDK/issues/1188
//More info on obtaining the HWND
var filePicker = new FileOpenPicker();
// Get the current window's HWND by passing in the Window object
var hwnd = WinRT.Interop.WindowNative.GetWindowHandle(this);
// Associate the HWND with the file picker
WinRT.Interop.InitializeWithWindow.Initialize(filePicker, hwnd);
// Use file picker like normal!
filePicker.FileTypeFilter.Add("*");
var file = await filePicker.PickSingleFileAsync();
if (file != null)
{
using (Windows.Storage.Streams.IRandomAccessStream randAccStream =
await file.OpenAsync(Windows.Storage.FileAccessMode.Read))
{
// Load the file into the Document property of the RichEditBox.
editor.Document.LoadFromStream(Microsoft.UI.Text.TextSetOptions.FormatRtf, randAccStream);
}
}
}
from winui-gallery.
Related Issues (20)
- Please update Winui gallery datagrid samples instruction HOT 2
- Crash when switching to page ”SemanticZoom“ HOT 5
- WinUI 3 Gallery has crashed twice in 5 minutes HOT 1
- Cannot implicitly convert "System.Drawing.Color" to ""Windows.Ui.Color" HOT 1
- How can sticky and center horizontally
- Selecting NavigationView quickly after other menu items crashes the app
- System.Runtime.InteropServices.COMException: 'Invalid window handle. (0x80070578) HOT 1
- Lack of C++/WinRT samples
- SemanticZoom page crashes appBug title HOT 1
- XAML STYLER as a Git-Hook HOT 9
- WinUI 2 Gallery Needs a setting to turn off UI objects that can not be used in UWP apps. HOT 1
- Winui 3 datagrid Row height is not working when we resize column
- multi-line TextBox Source code error
- WinUI 3 Gallery crashed when clicking Settings button HOT 3
- Title Bar Invisible when adding Frame
- NewControlsPage HOT 1
- The app crashes trying to show the search results page HOT 2
- The app version info is not updated to v2.3.0
- InfoBadge + FontIconSource
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from winui-gallery.