Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
147683 | Sep 19,2019 03:06 PM UTC | Oct 29,2019 09:12 AM UTC | UWP | 5 |
![]() |
Tags: SfCalculator |
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();
}
} |
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.