-1

I want to add a phone dialer key inside content page Layout not launch the Phone Dial outside application. I used Xamarin essential but its launch Device Phone Dialer out side application page

ahmed gaber
  • 77
  • 1
  • 8

1 Answers1

4

You may have to design it by yourself. Below are just rough codes for the UI design and blank logic just to give you an idea of how it can be done.

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="50"/>
        <RowDefinition Height="50"/>
        <RowDefinition Height="50" />
        <RowDefinition Height="50" />
        <RowDefinition Height="50" />
        <RowDefinition Height="50" />
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="*"/>
    </Grid.ColumnDefinitions>

    <Entry x:Name="phoneNumber" Grid.Row="0" Grid.ColumnSpan="3" />
    <Button Grid.Row="1" Grid.Column="0" Text="1" Clicked="Button_Clicked" />
    <Button Grid.Row="1" Grid.Column="1" Text="2" Clicked="Button_Clicked" />
    <Button Grid.Row="1" Grid.Column="2" Text="3" Clicked="Button_Clicked" />
    <Button Grid.Row="2" Grid.Column="0" Text="4" Clicked="Button_Clicked" />
    <Button Grid.Row="2" Grid.Column="1" Text="5" Clicked="Button_Clicked" />
    <Button Grid.Row="2" Grid.Column="2" Text="6" Clicked="Button_Clicked" />
    <Button Grid.Row="3" Grid.Column="0" Text="7" Clicked="Button_Clicked" />
    <Button Grid.Row="3" Grid.Column="1" Text="8" Clicked="Button_Clicked" />
    <Button Grid.Row="3" Grid.Column="2" Text="9" Clicked="Button_Clicked" />
    <Button Grid.Row="4" Grid.Column="1" Text="0" Clicked="Button_Clicked" />
    <Button Grid.Row="5" Grid.ColumnSpan="3" Text="Call" Clicked="Button_Clicked_1" />
</Grid>

The UI would look like below.

enter image description here

Your code-behind should be something like below.

private void Button_Clicked(object sender, EventArgs e)
{
    var enteredNumber = (sender as Button).Text;
    this.phoneNumber.Text += enteredNumber;
}

private void Button_Clicked_1(object sender, EventArgs e)
{
    //Logic to make a call
}

Refer to the below link on how to make a call programmatically. https://stackoverflow.com/a/37551969/2536167

I hope that helps.

Harikrishnan
  • 1,474
  • 2
  • 11
  • 25