基础知识(一)WPF与 Blend的关系,以及Blend如何快速生成xaml代码,即Path数据。

一、什么是Blend?

1、Blend是一款用于设计桌面和Web应用用户界面的可视化工具,用于UI设计,其功能和PS类似,但是比PS强大。其可以快速、精细地绘制图片,并可以生成.XAML文件,以便给VS工程使用。

2、VS自带有一款blend for visual studio,其是专门用来做WPF、Metro等的界面设计。其目的让做界面和后台的程序分开。VS与Blend之间,可以在菜单栏-视图 中自由切换使用。

3、blend for visual studio可以导入PS文件或其他图片,进一步加工成矢量图,并生成.xAMLW文件,给WPF、Metro等工程使用。

4、blend for visual studio和DrawingBrush常常结合一起使用,来制作自定义图片的。lend for visual studio初步生成粗略的.xaml代码,然后作为DrawingBrush自定义图片的一部分,最后在DrawingBrush自定义图片的中,对代码进行细化。综合来说,前期可以用Blend快速生成代码,后期可以用DrawingBrush把这些代码综合起来。

5、Blend 基础/样式/模板/控件模板/

https://www.cnblogs.com/clockdotnet/p/4188489.html

https://www.cnblogs.com/clockdotnet/p/4188530.html

https://www.cnblogs.com/clockdotnet/p/4188594.html

https://www.cnblogs.com/clockdotnet/p/4188607.html

https://www.cnblogs.com/clockdotnet/p/4320535.html

6、微软官网 使用 Blend for Visual Studio 创建 UI

https://msdn.microsoft.com/zh-cn/library/jj171012.aspx

7、Blend经典入门教程

https://wenku.baidu.com/view/ef2c321b58eef8c75fbfc77da26925c52cc59107.html

二、blend for visual studio与WPF的关系?

blend for visual studio快速生成UI给WPF工程使用,使得界面和后台的程序分开。

三、Blend如何快速生成xaml代码,即Path数据?

方法1:Blend图片文件转换为xaml代码的Path数据。

https://blog.csdn.net/dh164645822/article/details/77155701?fps=1&locationNum=8

Blend 2013版可以导入.PSD文件,但是Blend 2015版不能导入.PSD文件。因此软件工具需切换为 Expression Design:

https://www.cnblogs.com/lvdongjie/p/5479718.html

方法2:Blend工具可以自己画图,然后生成xaml代码的Path数据。该方法在我的后面几篇博客上,已经更加详细的阐述了。

https://blog.csdn.net/xpj8888/article/category/8094222

  • 7
    点赞
  • 61
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 5
    评论
以下是使用C#编写的WPF二维数据拟合代码: 1. 在XAML文件中添加一个Chart控件: <Window x:Class="WpfApp1.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:chartingToolkit="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit" mc:Ignorable="d" Title="MainWindow" Height="450" Width="800"> <Grid> <chartingToolkit:Chart Name="chart" Title="Data Fitting"> <chartingToolkit:Chart.Series> <chartingToolkit:LineSeries Name="lineSeries" Title="Data Points" /> <chartingToolkit:LineSeries Name="lineSeriesFitted" Title="Fitted Curve" /> </chartingToolkit:Chart.Series> <chartingToolkit:Chart.Axes> <chartingToolkit:LinearAxis Orientation="X" Title="X Axis" /> <chartingToolkit:LinearAxis Orientation="Y" Title="Y Axis" /> </chartingToolkit:Chart.Axes> </chartingToolkit:Chart> </Grid> </Window> 2. 在C#代码中添加以下方法: using System.Windows.Controls.DataVisualization.Charting; using System.Windows.Media; public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); // Generate some random data points double[] xValues = { 1, 2, 3, 4, 5 }; double[] yValues = { 2.2, 3.5, 4.1, 5.2, 6.7 }; // Add the data points to the chart for (int i = 0; i < xValues.Length; i++) { lineSeries.Points.Add(new DataPoint(xValues[i], yValues[i])); } // Fit the data points to a line double[] coefficients = FitLine(xValues, yValues); double slope = coefficients[0]; double yIntercept = coefficients[1]; // Add the fitted curve to the chart for (double x = 0; x < 6; x += 0.1) { double y = slope * x + yIntercept; lineSeriesFitted.Points.Add(new DataPoint(x, y)); } lineSeriesFitted.Stroke = Brushes.Red; } // Fit the data points to a line using least squares regression private double[] FitLine(double[] xValues, double[] yValues) { double sumX = 0; double sumY = 0; double sumXY = 0; double sumX2 = 0; for (int i = 0; i < xValues.Length; i++) { sumX += xValues[i]; sumY += yValues[i]; sumXY += xValues[i] * yValues[i]; sumX2 += xValues[i] * xValues[i]; } double slope = (xValues.Length * sumXY - sumX * sumY) / (xValues.Length * sumX2 - sumX * sumX); double yIntercept = (sumY - slope * sumX) / xValues.Length; return new double[] { slope, yIntercept }; } } 3. 运行程序,即可看到数据点和拟合曲线的图形。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

我爱AI

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值