回复 8楼不停息的翔龙的帖子
TX 有自己的 Loaded 标志位机制,所以需要在 tx loaded 事件中使用 Dispatcher.BeginInvoke 事件来加载字节流:
- Private Sub Window_Loaded(sender As Object, e As RoutedEventArgs)
- tabControl1.Items(1).Focus()
- End Sub
- Private Sub TabItem_GotFocus(sender As Object, e As RoutedEventArgs)
- End Sub
- Private Sub tx1_Loaded(sender As Object, e As RoutedEventArgs) Handles tx1.Loaded
- tx1.Dispatcher.BeginInvoke(New Action(AddressOf LoadFile))
- End Sub
- Private Sub LoadFile()
- Dim filename As String = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..\\..\\test1.tx")
- Dim stream As FileStream = File.Open(filename, FileMode.Open)
- Dim bytes() As Byte = New Byte(stream.Length) {}
- stream.Read(bytes, 0, bytes.Length)
- Me.tx1.Load(bytes, TXTextControl.BinaryStreamType.InternalFormat)
- stream.Close()
- End Sub
复制代码
Demo:
16953.zip
(140.26 KB, 下载次数: 339)
|