Skip to content

Latest commit

 

History

History
69 lines (49 loc) · 4.82 KB

2013-07-27-windows-phone-8-ile-telefonun-operatorunu-bulma.md

File metadata and controls

69 lines (49 loc) · 4.82 KB
layout title date author comments category tags
post
Windows Phone 8 ile telefonun operatörünü bulma
2013-07-27 20:00
engin.polat
true
Windows
background
button
cellularmobileoperator
content
contentcontrol
devicenetworkinformation
height
mainpage
messagebox
mobile
networkinformation
operatör
phoneaccentbrush
phoneapplicationpage
phonetextnormalstyle
phonetexttitle1style
property
sdk
stackpanel
static
staticresource
windows phone
windowsphone
wp8
xaml

Windows Phone 8 için geliştirdiğiniz uygulamanın çalıştığı telefonun bağlı olduğu operatör'ü bulmak isteyebilirsiniz.

Özellikle operatör'e özel seçenekler çıkartmak veya kısıtlamalar getirmek için bunu yapmaya ihtiyacınız olabilir.

Windows Phone 8 SDK içerisinde yer alan DeviceNetworkInformation sınıfında Mobil Operator bilgisini kolaylıkla almanızı sağlayan static tanımlı CellularMobileOperator özelliği mevcuttur.

Hemen yeni bir proje oluşturarak kullanımını inceleyelim;

MainPage.xaml dosyasını açarak sayfanın tasarımını değiştirelim. StackPanel içerisine bir Button nesnesi ekleyelim, Content özelliğine Tıkla, Background özelliğine StaticResource PhoneAccentBrush, Height özelliğine 120 değerlerini verelim;

<phone:PhoneApplicationPage x:Class="OperatorSample.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:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" FontFamily="{StaticResource PhoneFontFamilyNormal}" FontSize="{StaticResource PhoneFontSizeNormal}" Foreground="{StaticResource PhoneForegroundBrush}" SupportedOrientations="Portrait" Orientation="Portrait" shell:SystemTray.IsVisible="True">

&lt;StackPanel&gt;
    &lt;StackPanel x:Name="TitlePanel" Margin="12,17,0,28"&gt;
        &lt;TextBlock Text="http://www.enginpolat.com" Style="{StaticResource PhoneTextNormalStyle}" Margin="12,0"/&gt;
        &lt;TextBlock Text="operatör" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/&gt;
    &lt;/StackPanel&gt;

    &lt;StackPanel Margin="12,0,12,0"&gt;
        &lt;Button Content="Tıkla" Background="{StaticResource PhoneAccentBrush}" Height="120" Click="Button_OnClick" /&gt;
    &lt;/StackPanel&gt;
&lt;/StackPanel&gt;

</phone:PhoneApplicationPage>

Background özelliğine StaticResource listesinden PhoneAccentBrush değerini vererek, buton'un arkarengini kullanıcının tercih ettiği tema rengine ayarlamış olduk;

Button'a tıklandığında Button_OnClick() method'u tetiklenecek;

private void Button_OnClick(object sender, RoutedEventArgs e)
{
    var operatorAdi = DeviceNetworkInformation.CellularMobileOperator;

    MessageBox.Show(operatorAdi);
}


Butona tıkladığımızda ekrana, uygulamanın kurulu olduğu telefonun *mobil operatörü* gelmeli;

![](/assets/uploads/2013/07/OperatorSample-3.png)