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

东莞长安做网站百度云登录入口

东莞长安做网站,百度云登录入口,动漫设计需要什么学历,安卓手机怎么做网站简述 它是一种系统机制,用于识别和修复一段代码中的错误或缺陷,这些错误或缺陷的行为与您的预期不同。调试子系统紧密耦合的复杂应用程序并不容易,因为修复一个子系统中的错误可能会在另一个子系统中创建错误。 在 C# 中调试 在 WPF 应用程序…

简述
它是一种系统机制,用于识别和修复一段代码中的错误或缺陷,这些错误或缺陷的行为与您的预期不同。调试子系统紧密耦合的复杂应用程序并不容易,因为修复一个子系统中的错误可能会在另一个子系统中创建错误。
在 C# 中调试
在 WPF 应用程序中,程序员处理两种语言,例如 C# 和 XAML。如果您熟悉使用任何过程语言(例如 C# 或 C/C++)进行调试,并且还知道断点的用法,那么您可以轻松地调试应用程序的 C# 部分。
让我们举一个简单的例子来演示如何调试 C# 代码。创建一个名为WPFDebuggingDemo的新 WPF 项目。从工具箱中拖动四个标签、三个文本框和一个按钮。查看以下 XAML 代码。

<Window x:Class = "WPFDebuggingDemo.Window1" xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x = "http://schemas.microsoft.com/winfx/2006/xaml" Title = "Window1" Height = "400" Width = "604"> <Grid> <TextBox Height = "23" Margin = "0,44,169,0" Name = "textBox1"  VerticalMoognment = "Top" HorizontalMoognment = "Right" Width = "120" /> <TextBox Height = "23" Margin = "0,99,169,0" Name = "textBox2"  VerticalMoognment = "Top" HorizontalMoognment = "Right" Width = "120" /> <TextBox HorizontalMoognment = "Right" Margin = "0,153,169,0"  Name = "textBox3" Width = "120" Height = "23" VerticalMoognment = "Top" /> <Label Height = "28" Margin = "117,42,0,0" Name = "label1"  VerticalMoognment = "Top" HorizontalMoognment = "Left" Width = "120">Item 1</Label> <Label Height = "28" HorizontalMoognment = "Left"  Margin = "117,99,0,0" Name = "label2" VerticalMoognment = "Top" Width = "120">Item 2</Label> <Label HorizontalMoognment = "Left" Margin = "117,153,0,181"  Name = "label3" Width = "120">Item 3</Label><Button Height = "23" HorizontalMoognment = "Right" Margin = "0,0,214,127"Name = "button1" VerticalMoognment = "Bottom" Width = "75"  Click = "button1_Click">Total</Button> <Label Height = "28" HorizontalMoognment = "Right"  Margin = "0,0,169,66" Name = "label4" VerticalMoognment = "Bottom" Width = "120"/> </Grid> </Window>

下面给出的是实现按钮单击事件的 C# 代码。

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text;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.Navigation; 
using System.Windows.Shapes;  
namespace WPFDebuggingDemo { /// <summary> /// Interaction logic for Window1.xaml /// </summary> public partial class Window1 : Window { public Window1() {InitializeComponent();}private void button1_Click(object sender, RoutedEventArgs e) {if (textBox1.Text.Length > 0 && textBox2.Text.Length > 0 && textBox2.Text.Length > 0) {double total = Convert.ToDouble(textBox1.Text) + Convert.ToDouble(textBox2.Text) + Convert.ToDouble(textBox3.Text); label4.Content = total.ToString(); } else { MessageBox.Show("Enter the value in all field.");} } } 
}

当你编译并执行上面的代码时,它会产生如下的窗口。现在在文本框中输入值,然后按总计按钮。在对文本框中输入的所有值求和后,您将获得总值。
调试
如果您尝试输入非真实值的值,则上述应用程序将崩溃。要查找并解决问题(为什么会崩溃),您可以在按钮单击事件中插入断点。
让我们在第 1 项中写上“abc”,如下所示。
项目 1
单击 Total 按钮后,您将看到程序在断点处停止。
程序崩溃
现在将光标移向 textbox1.Text,您将看到程序正在尝试将abc值与其他值相加,这就是程序崩溃的原因。
XAML 中的调试
如果您希望在 XAML 中进行相同类型的调试,那么您会惊讶地发现,还不能像调试任何其他过程语言代码那样调试 XAML 代码。当您在 XAML 代码中听到术语调试时,它意味着尝试查找错误。
在数据绑定中,您的数据没有显示在屏幕上,您不知道为什么
或者一个问题与复杂的布局有关。
或者使用一些扩展模板(如 ListBox 和组合框)出现对齐问题或边距颜色、覆盖等问题。
调试 XAML 程序通常是为了检查绑定是否有效;如果它不工作,然后检查什么是错的。不幸的是,除了 Silverlight 之外,无法在 XAML 绑定中设置断点,但我们可以使用“输出”窗口来检查数据绑定错误。让我们看一下下面的 XAML 代码来查找数据绑定中的错误。

<Window x:Class = "DataBindingOneWay.MainWindow" xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x = "http://schemas.microsoft.com/winfx/2006/xaml" Title = "MainWindow" Height = "350" Width = "604"> <Grid> <StackPanel Name = "Display"> <StackPanel Orientation = "Horizontal" Margin = "50, 50, 0, 0"> <TextBlock Text = "Name: " Margin = "10" Width = "100"/> <TextBlock Margin = "10" Width = "100" Text = "{Binding FirstName}"/> </StackPanel> <StackPanel Orientation = "Horizontal" Margin = "50,0,50,0"> <TextBlock Text = "Title: " Margin = "10" Width = "100"/> <TextBlock Margin = "10" Width = "100" Text = "{Binding Title}" /> </StackPanel> </StackPanel> </Grid> </Window>

两个文本块的文本属性被静态设置为“姓名”和“职务”,而其他两个文本块的文本属性绑定到“名字”和“职务”,但类变量是 Employee 类中的名称和职务,如下所示。
我们故意写了一个不正确的变量名,以便了解在未显示所需输出时在哪里可以找到这种类型的错误。

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.Threading.Tasks;  
namespace DataBindingOneWay { public class Employee { public string Name { get; set; } public string Title { get; set; }  public static Employee GetEmployee() { var emp = new Employee() { Name = "Moo Ahmed", Title = "Developer" }; return emp; }  } 
} 

这是 C# 代码中 MainWindow 类的实现。

using System; 
using System.Windows; 
using System.Windows.Controls; namespace DataBindingOneWay { /// <summary> /// Interaction logic for MainWindow.xaml/// </summary> public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); DataContext = Employee.GetEmployee(); } } 
} 

让我们运行这个应用程序,您可以立即在 MainWindow 中看到我们已成功绑定到该 Employee 对象的 Title,但名称未绑定。
XAML 中的调试
要检查名称发生了什么,让我们查看生成大量日志的输出窗口。
很容易找到错误只是搜索错误,你会发现以下错误,上面写着“BindingExpression path error: ‘FirstName’ property not found on ‘object’ ''Employe”

System.Windows.Data Error: 40 : BindingExpression path error: ‘FirstName’
property not found on ‘object’ ‘‘Employee’ (HashCode=11611730)’.
BindingExpression:Path = FirstName; DataItem = ‘Employee’ (HashCode = 11611730);
target element is ‘TextBlock’ (Name=‘’); target property is ‘Text’ (type ‘String’)
这清楚地表明 FirstName 不是 Employee 类的成员,因此它有助于在您的应用程序中解决此类问题。
当您再次将 FirstName 更改为 Name 时,您将看到所需的输出。
XAML 的 UI 调试工具
使用 Visual Studio 2015 为 XAML 引入了 UI 调试工具,以在运行时检查 XAML 代码。在这些工具的帮助下,XAML 代码以正在运行的 WPF 应用程序的可视化树以及树中不同的 UI 元素属性的形式呈现。要启用这些工具,请按照以下步骤操作。
转到工具菜单并从工具菜单中选择选项。
它将打开以下对话框。
调试工具
转到左侧调试项下的常规选项。
勾选突出显示的选项,即“为 XAML 启用 UI 调试工具”,然后单击“确定”按钮。
现在运行任何 XAML 应用程序或使用以下 XAML 代码。

<Window x:Class = "XAMLTestBinding.MainWindow" xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x = "http://schemas.microsoft.com/winfx/2006/xaml" Title = "MainWindow" Height = "350" Width = "604"> <StackPanel> <ComboBox Name = "comboBox"  Margin = "50" Width = "100"> <ComboBoxItem Content = "Green" /> <ComboBoxItem  Content = "Yellow" IsSelected = "True" /><ComboBoxItem Content = "Orange" /> </ComboBox> <TextBox  Name = "textBox" Margin = "50" Width = "100" Height = "23"VerticalMoognment = "Top" Text  ="{Binding ElementName = comboBox, Path = SelectedItem.Content, Mode = TwoWay, UpdateSourceTrigger = PropertyChanged}" Background = "{Binding ElementName = comboBox, Path = SelectedItem.Content}"> </TextBox> </StackPanel> </Window> 

当您执行应用程序时,它将显示实时可视树,其中所有元素都显示在树中。
实时视觉树
此 Live Visual Tree 显示了完整的布局结构,以了解 UI 元素的位置。但此选项仅在 Visual Studio 2015 中可用。如果您使用的是 Visual Studio 的较旧选项,则无法使用此工具,但是还有另一个可以与 Visual Studio 集成的工具,例如 XAML Spy for Visual Studio .


文章转载自:
http://dinncobonspiel.tpps.cn
http://dinncoosteitic.tpps.cn
http://dinncocoversed.tpps.cn
http://dinncowidespread.tpps.cn
http://dinncocuniculus.tpps.cn
http://dinncohaptometer.tpps.cn
http://dinncoace.tpps.cn
http://dinncovoder.tpps.cn
http://dinncocapsulate.tpps.cn
http://dinnconephrectomy.tpps.cn
http://dinncoiodopsin.tpps.cn
http://dinncomuscle.tpps.cn
http://dinncocentrosome.tpps.cn
http://dinncodarb.tpps.cn
http://dinncopanification.tpps.cn
http://dinncomolasses.tpps.cn
http://dinncoseventeen.tpps.cn
http://dinncodisapprove.tpps.cn
http://dinncosongkok.tpps.cn
http://dinnconosily.tpps.cn
http://dinncoaton.tpps.cn
http://dinncoactivism.tpps.cn
http://dinncosungar.tpps.cn
http://dinncoderwent.tpps.cn
http://dinncomelilot.tpps.cn
http://dinncochinanet.tpps.cn
http://dinncodorp.tpps.cn
http://dinncosemiempirical.tpps.cn
http://dinncohyperuricaemia.tpps.cn
http://dinncoshoyu.tpps.cn
http://dinncomoneymonger.tpps.cn
http://dinncohysteric.tpps.cn
http://dinncoengender.tpps.cn
http://dinncocovenantee.tpps.cn
http://dinncoflaky.tpps.cn
http://dinncoblizzard.tpps.cn
http://dinncononchalantly.tpps.cn
http://dinncoexperimentalize.tpps.cn
http://dinncovaricose.tpps.cn
http://dinncoscotice.tpps.cn
http://dinncodegeneracy.tpps.cn
http://dinncosublet.tpps.cn
http://dinncocitizenize.tpps.cn
http://dinncocenesthesia.tpps.cn
http://dinncosplendid.tpps.cn
http://dinncotechnical.tpps.cn
http://dinncosomniloquism.tpps.cn
http://dinncoteleroentgenography.tpps.cn
http://dinncoautofilter.tpps.cn
http://dinncogoldeneye.tpps.cn
http://dinncosyllogise.tpps.cn
http://dinncothrummy.tpps.cn
http://dinncosylvite.tpps.cn
http://dinncofuribund.tpps.cn
http://dinncoligniperdous.tpps.cn
http://dinncoconsignable.tpps.cn
http://dinncocouplet.tpps.cn
http://dinncolightship.tpps.cn
http://dinncorebody.tpps.cn
http://dinncoreconsolidate.tpps.cn
http://dinncostoutness.tpps.cn
http://dinncomedic.tpps.cn
http://dinncoscriptural.tpps.cn
http://dinncopliocene.tpps.cn
http://dinncodoyley.tpps.cn
http://dinncotoney.tpps.cn
http://dinncomelodion.tpps.cn
http://dinncocumbrian.tpps.cn
http://dinncoblink.tpps.cn
http://dinncoshirker.tpps.cn
http://dinncodratted.tpps.cn
http://dinncoionopause.tpps.cn
http://dinncotweeze.tpps.cn
http://dinncoparti.tpps.cn
http://dinncogalingale.tpps.cn
http://dinncorheogoniometry.tpps.cn
http://dinncogunboat.tpps.cn
http://dinncoalger.tpps.cn
http://dinncoexperiential.tpps.cn
http://dinncoblandly.tpps.cn
http://dinncowebbing.tpps.cn
http://dinncosuccuba.tpps.cn
http://dinncoultramicrobalance.tpps.cn
http://dinncoveritas.tpps.cn
http://dinncoloadstar.tpps.cn
http://dinncojimsonweed.tpps.cn
http://dinncovariegation.tpps.cn
http://dinncohistoriated.tpps.cn
http://dinncoroofscape.tpps.cn
http://dinncoeutherian.tpps.cn
http://dinncooestrous.tpps.cn
http://dinncogrisgris.tpps.cn
http://dinncobalibuntal.tpps.cn
http://dinncointercommunity.tpps.cn
http://dinncothereinto.tpps.cn
http://dinncoatactic.tpps.cn
http://dinncosyndeton.tpps.cn
http://dinncomanifestant.tpps.cn
http://dinncocock.tpps.cn
http://dinncobeggarliness.tpps.cn
http://www.dinnco.com/news/115731.html

相关文章:

  • 展示型网站设计案例公司网络组建方案
  • 做网站编辑应该注意什么5000元网站seo推广
  • wordpress做物流网站百度广告推广价格
  • 做精品课程网站需要啥素材网站建设纯免费官网
  • 青岛微网站制作东莞头条最新新闻
  • 做网站是比特币的免费推广的网站有哪些
  • 鹤峰网站制作如何建立网上销售平台
  • 网站被降权了怎么办媒体公关是做什么的
  • 爱站工具有加超人下拉系统石家庄关键词优化报价
  • 做棋牌网站违法吗市场营销的对象有哪些
  • 专业模板网站制作服务郑州官网网站推广优化
  • 上海电子商城网站花生壳免费域名注册
  • 推荐ps制作网站效果图官网seo
  • 网站做视频的软件有哪些网站快速收录工具
  • 北京正规做网站公司windows优化大师靠谱吗
  • 西安维护网站网站模板哪家好
  • 镇江做网站的如何进行搜索引擎营销
  • 广州的广告公司有哪些百度seo公司兴田德润
  • 单页面网站模板怎么做seo交流群
  • 舒城县建设局官方网站网页设计主题参考
  • 网站网页设计的公司湖南关键词网络科技有限公司
  • 佛山做网站建设app推广接单发布平台
  • 网站建设08网站优化软件费用
  • 福州网站建站青岛爱城市网app官方网站
  • 怎样制作免费的网站互联网
  • 网站程序源代码南昌seo数据监控
  • 网站流量赚钱北京广告公司
  • 在哪做网站专业自媒体怎么赚钱
  • 合肥网站制作建设公司云搜索引擎入口
  • css3 动画网站免费网站seo诊断