.NET MAUI进行UDP通信(二)

上篇文章有写过一个简单的demo,本次对项目进行进一步的扩展,添加tabbar功能。

1.修改AppShell.xaml文件,如下所示:

csharp 复制代码
<?xml version="1.0" encoding="UTF-8" ?>
<Shell
    x:Class="mauiDemo.AppShell"
    xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:local="clr-namespace:mauiDemo"
    xmlns:minePage ="clr-namespace:mauiDemo.Page"
    Shell.FlyoutBehavior="Disabled"
    Title="mauiDemo">

    <!--<ShellContent
        Title="Home"
        ContentTemplate="{DataTemplate local:MainPage}"
        Route="MainPage" />-->

    <TabBar>
        <ShellContent Title="Home" 
                      ContentTemplate="{DataTemplate minePage:Mine}"
                      Route="Page/Mine">
            <!--<ContentPage>
                <StackLayout>
                    <Label Text="Welcome to the Home Page"
                           VerticalOptions="CenterAndExpand" 
                           HorizontalOptions="CenterAndExpand" />
                </StackLayout>
            </ContentPage>-->
        </ShellContent>
        <ShellContent Title="Search">
            <ContentPage>
                <StackLayout>
                    <Label Text="Search Page"
                           VerticalOptions="CenterAndExpand" 
                           HorizontalOptions="CenterAndExpand" />
                </StackLayout>
            </ContentPage>
        </ShellContent>
        <ShellContent Title="Settings">
            <ContentPage>
                <StackLayout>
                    <Label Text="Settings Page"
                           VerticalOptions="CenterAndExpand" 
                           HorizontalOptions="CenterAndExpand" />
                </StackLayout>
            </ContentPage>
        </ShellContent>
    </TabBar>
1).将MainPage注释掉
2).添加tabbar功能
3).第一个ShellConten的路由设置为Mine文件,注意到ContentTemplate="{DataTemplate minePage:Mine}",当前不是local,是因为我们引用了命名空间并命名为minePage: xmlns:minePage ="clr-namespace:mauiDemo.Page".
路由 Route="Page/Mine" 可结合上篇文章了解,在下面会贴出完整项目结构图

</Shell>

2.运行查看效果如下:

3.项目完整结构图如下:

4.关于后续项目的计划

csharp 复制代码
1).添加sqlite帮助类,以方便数据存储到手机本身
2).可将UDP通信换成mqtt通信,并结合http将数据放置服务器,以实现远程控制设备功能
3).添加低功耗蓝牙BLE通信功能,对于无网络情况下近距离与仪器设备进行通信
4).IOS包的发布与实机测验
5).桌面端UI与移动端UI美化,目前未考虑UI,简单的横竖布局
6).添加图表数据展示
7).和uniapp进行性能上比较(了解到目前APP端uniapp需要下载第三方UDP插件,在UTS下可以编写调用原生UDP通信的插件,但UTS属于uniAPP x,demo暂时还开始,不过uniapp支持混用UTS插件,目前已实现在uniapp中调用UTS分享自定义插件,年后测验一下UTS自定义udp插件)
相关推荐
pengyi8710151 小时前
独享IP池自动化维护方案,智能检测自动延长使用寿命
网络协议·tcp/ip·自动化
rockey6274 小时前
AScript异步执行与await关键字
c#·.net·script·eval·expression·异步执行·动态脚本
德思特4 小时前
通过 Wireshark 抓取串口命令
网络协议·测试工具·wireshark
叫我少年5 小时前
ASP.NET Core 最小 API 快速参考
.net·api
KnowSafe6 小时前
2026年SSL证书市场便宜且安全的SSL证书调研
网络协议·安全·ssl
dangdanding9 小时前
防火墙 IP 分片测试套件-fragroute
linux·网络·网络协议·tcp/ip
TechWayfarer9 小时前
AI大模型时代:IP数据云如何适配智能体场景需求
开发语言·人工智能·python·网络协议·tcp/ip·langchain
cui_ruicheng10 小时前
Linux网络编程(五):基于UDP实现DictServer
linux·服务器·网络·udp
冰冰的米咖11 小时前
交换与路由技术整理与总结(持续更新版)
网络·网络协议·智能路由器
Ether IC Verifier12 小时前
TCP/IP协议握手原理详解——结合以太网连接过程
服务器·网络·数据库·网络协议·tcp/ip