首页
统计
壁纸
留言板
友情链接
更多
直播
实用工具
Search
1
浏览器 | 开启Chrome和Edge的多线程下载功能(Parallel downloading)
1,761 阅读
2
给孙小姐的一封情书
524 阅读
3
LabVIEW | 各版本及开发工具模块下载
293 阅读
4
armUbuntu系统构建
281 阅读
5
OpenWRT | 作为 旁路由/单臂路由/透明网关 设置 DDNS
270 阅读
取次花丛懒回顾
默认分类
C#
MySQL
LabVIEW
Java
Android
PHP
Python
handsome
相册
百度地图
嵌入式
嵌入式Ubuntu
I.MX6ULL
linux
Unity
Golang
Rust
OpenHD
教学计划
Search
标签搜索
C#
handsome
Git
动态壁纸
开源
Unity3d
Unity
csharp
Moao
累计撰写
183
篇文章
累计收到
25
条评论
首页
栏目
取次花丛懒回顾
默认分类
C#
MySQL
LabVIEW
Java
Android
PHP
Python
handsome
相册
百度地图
嵌入式
嵌入式Ubuntu
I.MX6ULL
linux
Unity
Golang
Rust
OpenHD
教学计划
页面
统计
壁纸
留言板
友情链接
直播
实用工具
搜索到
14
篇与
的结果
2020-05-18
WPF MVVM手敲简单框架
好处是,XAML界面Binding到数据后,只需要更新数据,无需再次手动绑定即可完成界面更新。1.创捷数据类,Model。例如我创建的CarInfo.csnamespace MVVMDemo1 { public class CarInfo { string CarName_; string CarID_; public string CarName { get { return CarName_; } set { CarName_ = value; } } public string CarID { get { return CarID_; } set { CarID_ = value; } } } }2.创建视图数据类,ViewModel。例如我创建的CarInfoViewModel.csusing System.ComponentModel; namespace MVVMDemo1 { public class CarInfoViewModel : INotifyPropertyChanged { CarInfo CarInfo_; public CarInfoViewModel() { CarInfo_ = new CarInfo() {CarName="河南1",CarID="HMB001" }; } public string CarName { get { return CarInfo_.CarName; } set { CarInfo_.CarName = value; RaisePropertyChanged("CarName"); } } public string CarID { get { return CarInfo_.CarID; } set { CarInfo_.CarID = value; RaisePropertyChanged("CarID"); } } /// <summary> /// 实现接口 /// </summary> public event PropertyChangedEventHandler PropertyChanged; private void RaisePropertyChanged(string propertyInfo) { PropertyChangedEventHandler handler = PropertyChanged; if(handler != null) { handler(this,new PropertyChangedEventArgs(propertyInfo)); } } } }3.视图界面声明视图模型Xaml文件中声明视图模型<Window x:Class="MVVMDemo1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:MVVMDemo1" mc:Ignorable="d" Title="MainWindow" Height="450" Width="800"> <Window.DataContext> <!--声明创建一个CarViewModel的实例--> <local:CarInfoViewModel/> </Window.DataContext> <Grid> <TextBox HorizontalAlignment="Left" Height="23" Margin="10,10,0,0" TextWrapping="Wrap" Text="{Binding CarName}" VerticalAlignment="Top" Width="120"/> <TextBox HorizontalAlignment="Left" Height="23" Margin="10,38,0,0" TextWrapping="Wrap" Text="{Binding CarID}" VerticalAlignment="Top" Width="120"/> <Button Content="Button" HorizontalAlignment="Left" Margin="195,145,0,0" VerticalAlignment="Top" Width="75" Click="Button_Click"/> </Grid> </Window>4.关联数据上下文主界面后台关联上下文,实现自动刷新数据using System.Windows; namespace MVVMDemo1 { /// <summary> /// MainWindow.xaml 的交互逻辑 /// </summary> public partial class MainWindow : Window { CarInfoViewModel carInfoViewModel; /// <summary> /// 视图模型 /// </summary> public MainWindow() { InitializeComponent(); //已经在xaml代码中声明了视图模型实例,获取到引用因此我们可以在按钮click事件里使用它 carInfoViewModel = base.DataContext as CarInfoViewModel; } /// <summary> /// 更改数据 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Button_Click(object sender, RoutedEventArgs e) { //更改数据,界面实时更新 carInfoViewModel.CarID = ""; } } }End
2020年05月18日
199 阅读
1 评论
0 点赞
2020-05-11
WPF UI框架 MahApps.Metro
安装您可以MahApps.Metro通过NuGet UI或程序包管理器控制台进行安装。在App.xaml(v1.6.5和更早版本)中添加资源<Application x:Class="WpfApplication.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" StartupUri="MainWindow.xaml"> <Application.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" /> <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" /> <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml" /> <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Blue.xaml" /> <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseLight.xaml" /> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Application.Resources> </Application> 在v2.0中的App.xaml中添加资源(重大更改)<Application x:Class="WpfApplication.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" StartupUri="MainWindow.xaml"> <Application.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" /> <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" /> <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Themes/Light.Blue.xaml" /> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Application.Resources> </Application> 在主窗口中将Window更改为MetroWindow<Controls:MetroWindow x:Class="WpfApplication.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Controls="http://metro.mahapps.com/winfx/xaml/controls" Title="MainWindow" Height="600" Width="800"> <Grid> <!-- your content --> </Grid> </Controls:MetroWindow> using MahApps.Metro.Controls; namespace WpfApplication { public partial class MainWindow : MetroWindow { public MainWindow() { InitializeComponent(); } } } 完整的MahApps文档可从https://mahapps.com获得。
2020年05月11日
112 阅读
0 评论
0 点赞
2020-04-26
基于GMap.Net的地图解决方案(包括调用第三方百度高德等地图)
https://www.cnblogs.com/luxiaoxun/p/3802559.html
2020年04月26日
100 阅读
0 评论
0 点赞
2020-04-26
WPF GMap.Net开发
GMap.NET是什么?来看看它的官方说明:GMap.NET is great and Powerful, Free, cross platform, open source .NET control. Enable use routing, geocoding, directions and maps from Coogle, Yahoo!, Bing, OpenStreetMap, ArcGIS, Pergo, SigPac, Yendux, Mapy.cz, Maps.lt, iKarte.lv, NearMap, OviMap, CloudMade, WikiMapia, MapQuest in Windows Forms & Presentation, supports caching and runs on windows mobile!GMap.NET是一个强大、免费、跨平台、开源的.NET控件,它在Windows Forms 和WPF环境中能够使用来自Google, Yahoo!, Bing, OpenStreetMap, ArcGIS, Pergo, SigPac等地图,并可以实现寻找路径、地理编码以及地图展示功能,并支持缓存和运行在Mobile环境中。项目主页:https://greatmaps.codeplex.com/Gmap下载下载GMap.Net,编译三个核心项目:GMap.Net.Core:核心DLLGMap.Net.WindowsForms:WinForm中使用的DLLGMap.NET.WindowsPresentation:WPF中使用的DLL如何在WPF中使用GMap.Net1、新建一个Visual C# 的WPF程序。添加对GMap.Net.Core.DLL和GMap.NET.WindowsPresentation.DLL的引用。2、由于WPF的UserControl不能修改继承的基类,所以添加一个新的类,为MapControl.cs,代码如下:using System; using System.Collections.Generic; using System.Linq; using System.Text; using GMap.NET.WindowsPresentation; namespace _7LocationNavigation { class MapControl: GMapControl { } } 只需要继承GMapControl就行了,基本功能都可以由GMapControl提供。3、在我们的MainWindow.xaml中,添加项目的namespace:xmlns:src="clr-namespace:GMapWPFDemo",在XML代码中添加对MapControl.cs的使用:<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:_7LocationNavigation" xmlns:WindowsPresentation="clr-namespace:GMap.NET.WindowsPresentation;assembly=GMap.NET.WindowsPresentation" x:Class="_7LocationNavigation.MainWindow" mc:Ignorable="d" xmlns:src="clr-namespace:_7LocationNavigation" Title="MainWindow" Height="450" Width="800"> <Grid> <GroupBox Header="GroupBox" HorizontalAlignment="Left" Height="401" Margin="10,10,0,0" VerticalAlignment="Top" Width="773"> <src:MapControl x:Name="mapControl" Zoom="13" MaxZoom="24" MinZoom="1" /> </GroupBox> </Grid> </Window>4、在MainWindow中添加相关的代码如下:引用using GMap.NET; using GMap.NET.MapProviders; using GMap.NET.WindowsPresentation;代码 try { System.Net.IPHostEntry e = System.Net.Dns.GetHostEntry("map.baidu.com"); } catch { mapControl.Manager.Mode = AccessMode.CacheOnly; MessageBox.Show("No internet connection avaible, going to CacheOnly mode.", "GMap.NET Demo", MessageBoxButton.OK, MessageBoxImage.Warning); } mapControl.MapProvider = GMapProviders.GoogleChinaMap; //google china 地图 mapControl.MinZoom = 2; //最小缩放 mapControl.MaxZoom = 17; //最大缩放 mapControl.Zoom = 5; //当前缩放 mapControl.ShowCenter = false; //不显示中心十字点 mapControl.DragButton = MouseButton.Left; //左键拖拽地图 mapControl.Position = new PointLatLng(32.064, 118.704); //地图中心位置:南京 mapControl.MouseLeftButtonDown += new MouseButtonEventHandler(mapControl_MouseLeftButtonDown); } void mapControl_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { Point clickPoint = e.GetPosition(mapControl); PointLatLng point = mapControl.FromLocalToLatLng((int)clickPoint.X, (int)clickPoint.Y); GMapMarker marker = new GMapMarker(point); mapControl.Markers.Add(marker); }参考文章:https://www.cnblogs.com/luxiaoxun/p/3463250.htmlhttps://blog.csdn.net/wshk918/article/details/103076060
2020年04月26日
104 阅读
0 评论
0 点赞
2020-04-23
C#通过SharpCifs访问操作Windows(smb)共享目录方法代码
https://www.cjavapy.com/article/395/
2020年04月23日
85 阅读
0 评论
0 点赞
1
2
3