6 Mart 2015 Cuma

SilverLight 4.0 Kes, Yapıştır ve Kapat (Cut, Paste, Page Close)

Visual Studio veya Expression Blend ile yeni bir silverlight projesi oluşturun.
  • MainPage.xaml Dosyası İçeriği;
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="sayfakapatma.MainPage"
Width="640" Height="480">
<Grid x:Name="LayoutRoot" Background="White">
<StackPanel>
<Button x:Name="btnKes" Content="Kes" Click="btnKes_Click" />
<Button x:Name="btnYapistir" Content="Yapıştır" Click="btnYapistir_Click" />
<TextBox x:Name="txtMetin" Height="175" Margin="0,0,1,0" />
<Button Content="Sayfayı Kapat" Click="Button_Click"/>
</StackPanel>
</Grid>
</UserControl>
  • MainPage.xaml.cs dosyasının içeriği;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
namespace sayfakapatma
{
public partial class MainPage : UserControl
{
public MainPage()
{
// Required to initialize variables
InitializeComponent();
}
private void Button_Click(object sender, System.Windows.RoutedEventArgs e)
{
// TODO: Add event handler implementation here.
System.Windows.Browser.HtmlPage.Window.Invoke("close");
}
private void btnKes_Click(object sender, System.Windows.RoutedEventArgs e)
{
// TODO: Add event handler implementation here.
Clipboard.SetText(txtMetin.Text);
txtMetin.Text = txtMetin.Text.Remove(txtMetin.SelectionStart, txtMetin.SelectionLength);
}
private void btnYapistir_Click(object sender, System.Windows.RoutedEventArgs e)
{
// TODO: Add event handler implementation here.
string textyukle = string.Empty;
textyukle = Clipboard.GetText();
txtMetin.Text = textyukle;
}
}
}

Hiç yorum yok :

Yorum Gönder