wpfでwpfにコードを書いて、2つの数字を受け入れることで、指数関数を表示します。 私は1つのコンバータ関数とコードを作成しました.. "Microsoft Visual Studioに問題が発生したため、終了する必要があります"というエラーが表示されます。その後、[送信しない]をクリックするとVs2010が終了します。 これは何が問題なのでしょうか?コードは...ここに添付されてVisual StudioがなぜこのWpfのxmalコードを書くときに閉じるのですか
namespace WpfTutSamples
{
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>
に
ObjectDataProvider
ことによってそれを参照してください? –