XAML
<input:SfCalculator x:Name="calculator" Width="400" DisplayText="{Binding DisplayText,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Expression="{Binding ExpressionText,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Style="{StaticResource DefaultSfCalculatorStyle}" FunctionsPaneStyle="{StaticResource SfCalculatorFunctionsPaneStyle1}" Height="600" />
<input:CalculatorButton Key="Number7" Command="{Binding CalculatorExpression}" IsTabStop="False" Foreground="{TemplateBinding Foreground}"
Content="7" x:Name="Digit7" >
<input:CalculatorButton x:Name="PART_Button17" BrushOpacity="0.3" Click="PART_Button17_Click" Command="{Binding ComputeValue}" CommandParameter="{Binding ElementName=calculator, Path=Value}" Content="=" Grid.Column="4" Function="Return" Foreground="{TemplateBinding Foreground}" FontSize="35" IsTabStop="False" Grid.RowSpan="2" Grid.Row="4"/>
Result:
<input:CalculatorButton x:Name="PART_Button17" BrushOpacity="0.3" Click="PART_Button17_Click" Command="{Binding ComputeValue}" CommandParameter="{Binding ElementName=calculator, Path=Value}" Content="=" Grid.Column="4" Function="Return" Foreground="{TemplateBinding Foreground}" FontSize="35" IsTabStop="False" Grid.RowSpan="2" Grid.Row="4"/>
C#
private void Expression(object obj)
{
_expression = ExpressionText + DisplayText;
}
private void ComputationValue(object obj)
{
if (obj != null)
{
var result = obj;
ContentDialog dialog = new ContentDialog();
dialog.Content = "Expression is : " + _expression + "\n" + "Result is : " + result.ToString();
dialog.IsPrimaryButtonEnabled = true;
dialog.PrimaryButtonText = "Ok";
dialog.PrimaryButtonClick += Dialog_PrimaryButtonClick;
dialog.ShowAsync();
}
} |