当前位置: 首页 > news >正文

c# wpf LiveCharts 绑定 简单试验

1.概要

c# wpf LiveCharts 绑定 简单试验

2.代码

<Window x:Class="WpfApp3.Window2"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:lvc="clr-namespace:LiveCharts.Wpf;assembly=LiveCharts.Wpf"xmlns:local="clr-namespace:WpfApp3"mc:Ignorable="d"Title="Window2" Height="450" Width="800"><Grid><lvc:CartesianChart Series="{Binding Series}" LegendLocation="Bottom"/></Grid>
</Window>
using LiveCharts.Wpf.Charts.Base;
using LiveCharts.Wpf;
using LiveCharts;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.ComponentModel;
using System.Runtime.CompilerServices;namespace WpfApp3
{/// <summary>/// Window2.xaml 的交互逻辑/// </summary>public partial class Window2 : Window{public Window2(){InitializeComponent();this.DataContext = new HomePgVM();}}public class HomePgVM : NotifyPropertyBase{public SeriesCollection Series { get; set; }public HomePgVM(){Series = new SeriesCollection(){new LineSeries{Title="充值",DataLabels=true,Values = new ChartValues<double> { 23, 15, 47, 64,30,32,21 },//Fill=new SolidColorBrush(Colors.LightGreen),},};}}/// <summary>/// 绑定UI显示--创建通知基类/// 继承 INotifyPropertyChanged(作用:当属性发生变化时,传递变化属性的值)/// </summary>public class NotifyPropertyBase : INotifyPropertyChanged{public event PropertyChangedEventHandler PropertyChanged;public void Notify([CallerMemberName] string propName = ""){if (PropertyChanged != null)PropertyChanged(this, new PropertyChangedEventArgs(propName));}protected void SetProperty<T>(ref T prop, T value, [CallerMemberName] string propertyName = null){if (EqualityComparer<T>.Default.Equals(prop, value) == false){prop = value;Notify(propertyName);}}}
}

 

3.运行结果

http://www.lryc.cn/news/333403.html

相关文章:

  • 【Kafka】Kafka安装、配置、使用
  • 2024HW-->Wireshark攻击流量分析
  • Lafida多目数据集实测
  • excel wps中编码格式转换
  • 【游戏分析】非游戏领空追字符串来源
  • golang 数组和切片
  • 物联网实战--入门篇之(九)安卓QT--开发框架
  • 【leetcode面试经典150题】16.接雨水(C++)
  • 互联网面经
  • xss介绍及作用
  • PostgreSQL入门到实战-第二弹
  • 3-【PS让图片动起来】系列1-【导入素材】
  • 基于Java+SpringBoot+Mybaties+layui+Vue+elememt 实习管理系统 的设计与实现
  • 非关系型数据库——Redis基本操作
  • golang语言和JAVA对比
  • 隐私计算实训营学习九:隐语多方安全计算在安全核对的行业实践
  • C#实现只保存2天的日志文件
  • C++ 类和对象(中篇)
  • 可视化场景(9):智慧看板,可能是最直观的数据展示
  • 加密算法(二)
  • 大创项目推荐 深度学习 YOLO 实现车牌识别算法
  • IP知识详解
  • 设计模式:适配器模式
  • 大语言模型落地的关键技术:RAG
  • ffmpeg Android 笔记
  • 本地创建新分支并提交gitee
  • [蓝桥杯 2019 国 C] 数正方形
  • Redis: 配置文件详解(Redis.conf)
  • 学习vue3第十四节 Teleport 内置组件介绍
  • mybatis模糊查询查不到数据