为什么在编写此Wpf xmal代码时Visual Studio关闭 [英] Why the VisualStudio Closing when i write this Wpf xmal code

查看:119
本文介绍了为什么在编写此Wpf xmal代码时Visual Studio关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

海,
我已经在wpf中编写了一个代码,通过接受两个数字来显示指数
为此,我创建了一个转换器函数和代码. 但是在编写这段代码后,它显示出类似
的错误 "Microsoft Visual Studio遇到问题,必须关闭".然后,当我们单击不发送"时,将关闭Vs2010.
那可能是什么问题?代码附在这里...


Hai,
i have written a code in wpf to show the Exponential , by accepting the two numbers
for that i have created one converter function and code..
but when after writing this code it showing error like
"Microsoft Visual Studio encountered a problem and it has to Closed"..then when we click on Don''t send it closes the Vs2010.
What might be the problem for that? the code is attached here...


namespace WpfTutSamples
{
    /// <summary>
    /// Interaction logic for Exponential.xaml
    /// </summary>
    public partial class Exponential : Window
    {
        public Exponential()
        {
            InitializeComponent();
        }
        public double GetValue(double number, double exponent)
        {
            double value = Math.Pow(number, exponent);
            return value;

        }
    }
}



    -----XmlCode

 <Window x:Class="WpfTutSamples.Exponential"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:WpfTutSamples"
        xmlns:sys="clr-namespace:System;assembly=mscorlib"
        Title="Exponential" Height="300" Width="300">
    
    <Window.Resources>
        <ObjectDataProvider x:Key="expCalculator" MethodName="GetValue" ObjectType="{x:Type local:Exponential}">
            <ObjectDataProvider.MethodParameters>
                <sys:Double>4</sys:Double>
                <sys:Double>2</sys:Double>
            </ObjectDataProvider.MethodParameters>
        </ObjectDataProvider>
    </Window.Resources>


    <Grid>

        <Label Content="Number" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="2"> </Label>

        <TextBox HorizontalAlignment="Left" x:Name="txtNumber" Height="30" VerticalAlignment="Top" Margin="70,1" Width="60"
                 Text="{Binding Source={StaticResource expCalculator}, Path=MethodParametes[0], Mode=OneWayToSource, BindsDirectlyToSource=True}"></TextBox>


        <Label Content="Number" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="2,40"> </Label>
        <TextBox HorizontalAlignment="Left" x:Name="txtpower" Height="30" VerticalAlignment="Top" Margin="70,40" Width="60"
                 Text="{Binding Source={StaticResource expCalculator}, Path=MethodParametes[1], Mode=OneWayToSource, BindsDirectlyToSource=True}"></TextBox>


<Label Content="Result" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="2,80"> </Label>
        <TextBox HorizontalAlignment="Left" x:Name="txtResult" Height="30" VerticalAlignment="Top" Margin="70,80" Width="60"
                 Text="{Binding Source={StaticResource expCalculator}}"></TextBox>

    </Grid>
</Window>

推荐答案

在EventViewer中进行查看.当Visual Studio崩溃时,它会写入事件日志,您应该找到它认为存在问题的详细信息.
Have a look in EventViewer. When Visual Studio crashes, it writes to the event log, and you should find the details of what it thinks the problem is there.


i我知道了,

实际上..我们不应该在同一个类中创建该方法,我们必须在另一个类中创建该方法(GetValue)并从该类中使用它,现在它可以正常工作...
i Got it,

actually .. we should not create that method in that same class ,, we have to create that method(GetValue) in another class and consume it from that class ,, it working fine now...


这篇关于为什么在编写此Wpf xmal代码时Visual Studio关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆