1/24/2010

SilverLight 簡単サンプル


どうもJudaです。



MainPage.xaml.cs



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 SilverBullet
{
public partial class MainPage : UserControl
{
//BookmarkList m_listBookmark = null;
TextBox m_txtBox_UserId = null;
TextBox m_txtBox_UserPwd = null;
TextBlock m_txtBlk_UserId = null;
TextBlock m_txtBlk_UserPwd = null;
string m_userId = null;
string m_userPwd = null;

public TextBox TxtBox_UserId
{
get { return m_txtBox_UserId; }
set { m_txtBox_UserId = value; }
}
public TextBox TxtBox_UserPwd
{
get { return m_txtBox_UserPwd; }
set { m_txtBox_UserPwd = value; }
}
public TextBlock TxtBlock_UserId
{
get { return m_txtBlk_UserId; }
set { m_txtBlk_UserId = value; }
}
public TextBlock TxtBlock_UserPwd
{
get { return m_txtBlk_UserPwd; }
set { m_txtBlk_UserPwd = value; }
}
public string UserId
{
get { return m_userId; }
set
{
m_userId = value;
TxtBlock_UserId.Text = value;
}
}
public string UserPwd
{
get { return m_userPwd; }
set
{
m_userPwd = value;
TxtBlock_UserPwd.Text = value;
}
}

public MainPage()
{
InitializeComponent();

m_txtBox_UserId = txtBox_UserId;
m_txtBox_UserPwd = txtBox_UserPwd;

m_txtBlk_UserId = lbl_UserId;
m_txtBlk_UserPwd = lbl_UserPwd;
}

private void btn_Login_Click(object sender, RoutedEventArgs e)
{
UserId = m_txtBox_UserId.Text;
UserPwd = m_txtBox_UserPwd.Text;
messageTxt.Text = "Hit";
}

private void txtBox_UserControl_GotFocus(object sender, RoutedEventArgs e)
{
if (sender is TextBox)
{
TextBox txtBox = (TextBox)sender;
txtBox.Text = "";
}
}
}
}

MainPage.xaml



MainPage.xmlを投稿しようとしたが、上手くいかない。XMLの構文を解釈されてしまうので、掲載しにくいです。
今日気がついたことは、位置情報をきっちり決めようとすると、Gridの要素としてCanvasを登録して、さらにその要素としてTextBlockなどを設定。そのプロパティとしてCanvas.Left,Canvas.Topを設定すると明確に位置合わせができます。

0 件のコメント:

コメントを投稿