Today, in this article let' dig out with one more wonderful concept in windows phone whereby communicating with WCF Service to perform some expected arithmetic operation. Once Implemented, it gives flexibility to the user to access phone pivot features and perform expected operation in much easy manner.
Question Arises: What is Pivot Control?
In Simple Terms "It is a simple light-weighted control which enables phone user to manage or navigate across different pages very easily. It enables the tasks to be turned on easily. It can be viewed from left to right or right to left depends upon screen touch scrolling by the user."
So, let's get it started off!!!
Step 1: The Complete Code of IService1.cs looks like this:
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Runtime.Serialization;
using
System.ServiceModel;
using
System.ServiceModel.Web;
using
System.Text;
namespace
Pivot_WCF
{
// NOTE: You can use the "Rename" command on the "Refactor"
menu to change the interface name "IService1" in both code and config file
together.
[ServiceContract]
public interface
IService1
{
[OperationContract]
double Add(double
a, double b);
[OperationContract]
double Sub(double
a, double b);
[OperationContract]
double Mul(double
a, double b);
[OperationContract]
double Div(double
a, double b);
}
}
Step 2: The Complete Code of Service1.svc.cs looks like this:
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Runtime.Serialization;
using
System.ServiceModel;
using
System.ServiceModel.Web;
using
System.Text;
namespace
Pivot_WCF
{
// NOTE: You can use the "Rename" command on the "Refactor"
menu to change the class name "Service1" in code, svc and config file together.
public class
Service1 : IService1
{
public
double Add(double
a, double b)
{
return a + b;
}
public
double Sub(double
a, double b)
{
return a - b;
}
public
double Mul(double
a, double b)
{
return a * b;
}
public
double Div(double
a, double b)
{
return a / b;
}
}
}
Step 3: The Complete Code of Web.Config looks like this:
<?xml
version="1.0"?>
<configuration>
<system.web>
<compilation
debug="true"
targetFramework="4.0"
/>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid
disclosing metadata information, set the value below to false and remove the
metadata endpoint above before deployment
-->
<serviceMetadata
httpGetEnabled="true"/>
<!--
To receive exception details in faults for debugging purposes, set the value
below to true. Set to false before deployment to avoid disclosing exception
information -->
<serviceDebug
includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment
multipleSiteBindingsEnabled="true"
/>
</system.serviceModel>
<system.webServer>
<modules
runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
Step 4: The Complete Code of MainPage.xaml looks like this:
<phone:PhoneApplicationPage
x:Class="Pivot_Control_Application.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignWidth="480"
d:DesignHeight="768"
d:DataContext="{d:DesignData
SampleData/MainViewModelSampleData.xaml}"
FontFamily="{StaticResource
PhoneFontFamilyNormal}"
FontSize="{StaticResource
PhoneFontSizeNormal}"
Foreground="{StaticResource
PhoneForegroundBrush}"
SupportedOrientations="Portrait"
Orientation="Portrait"
shell:SystemTray.IsVisible="True">
<!--LayoutRoot
is the root grid where all page content is placed-->
<Grid
x:Name="LayoutRoot"
Background="Transparent">
<!--Pivot Control-->
<controls:Pivot
Title="Vijay's Pivot
Application via WCF Service" FontFamily="Verdana"
FontSize="22">
<!--Pivot item one-->
<controls:PivotItem
Header="Addition">
<!--Double line list with
text wrapping-->
<StackPanel
x:Name="stackpanel1"
Width="500"
FlowDirection="LeftToRight"
>
<TextBlock x:Name="textBlock1"
FontFamily="Verdana"
FontSize="22"
Text="Please Enter First
Number" Height="60"
Width="293"
/>
<TextBox
Width="266"
x:Name="textbox1"></TextBox>
<TextBlock
x:Name="textBlock2"
Text="Please Enter
Second Number" FontFamily="Verdana"
FontSize="22"
Height="57"
Width="322"
/>
<TextBox
x:Name="textbox2"
Width="254"
/>
<Button
Content="Addition"
FontFamily="Verdana"
FontSize="22"
x:Name="btnAdd1"
Width="249"
Click="btnAdd1_Click"/>
<TextBlock
x:Name="textBlock3"
FontFamily="Verdana"
Foreground="Red"
FontSize="22"
Width="352"
Height="54"
/>
</StackPanel>
</controls:PivotItem>
<!--Pivot item two-->
<controls:PivotItem
Header="Substract">
<!--Triple line list no text
wrapping-->
<StackPanel
x:Name="stackpanel2"
Width="500"
FlowDirection="LeftToRight"
>







Join the conversation! Your thoughts help the community grow.