我正在尝试创建类似于macOS Finder列视图的触摸屏界面,这是一系列水平堆叠列表,其中每个列表都可以单独滚动(垂直),整个事物可以水平滚动,如下所示:
这是我的.NET 4.6.1"最小可行代码示例"来演示我正在做的事情:
前端:
<Window x:Class="TestNestedScroll.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:TestNestedScroll"
Title="MainWindow" Height="500" Width="800"
DataContext="{Binding RelativeSource={RelativeSource Self}}">
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Disabled" PanningMode="HorizontalOnly">
<ItemsControl ItemsSource="{Binding Columns}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" PanningMode="VerticalOnly">
<ItemsControl ItemsSource="{Binding Rows}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Rectangle Width="300" Height="100" Fill="Purple" Margin="20"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</Window>
Run Code Online (Sandbox Code Playgroud)
后端:
using System.Collections.Generic;
using System.Linq;
using System.Windows;
namespace TestNestedScroll
{
public partial class MainWindow : Window
{
public class Row {}
public class Column { public …
Run Code Online (Sandbox Code Playgroud) 可能我将数据发送到服务器并使用以下代码在 ============ 行之间获取数据,即使是非常大的数据。这是我的实验,因为我需要一些中间解决方案,以便我可以将 Flutter 应用程序连接到 tcp 套接字。为此,我选择 auqeduct.io。今天来自 Gazi 的帮助我找到了在 ============ 行之间完成我的代码的解决方案。
因为我正在使用 auqeduct,他们的句柄函数看起来像这样。
@override
Future<RequestOrResponse> handle(Request request) async {
Run Code Online (Sandbox Code Playgroud)
因此,我尝试修改我的代码并使用 Future 将套接字数据作为字符串返回。我可以在 ============ 行之间使用下面的代码获取数据,但是我无法使用 Future _handle(String _request) 异步获取任何数据。
_socket.listen((data) 打印数据无法将数据分配给字符串,因此我无法返回字符串。
作品: print("(1) $_secureResponse");
不起作用: _secureResponse = new String.fromCharCodes(data).trim();
如果我不使用 Future 并将代码放在 main() 中,则一切正常。
在我的测试服务器中,我发送了一个“Hello World”,作为回报,我得到了“欢迎先生/女士”。
我的问题是:如何从 Dart 中的 Future 返回套接字数据?
import 'dart:async';
import 'dart:io';
import 'dart:convert';
Socket socket;
String _errorData;
String _secureResponse;
void main() async {
var _test = await _handle("Hello World");
print("Print _test: $_test");
}
Future<String> _handle(String _request) …
Run Code Online (Sandbox Code Playgroud)