Silverlight Full Screen
private void toggleButton_Click(object sender, RoutedEventArgs e)
{
Content contentObject = Application.Current.Host.Content;
contentObject.IsFullScreen = !contentObject.IsFullScreen;
}
//Captch full screen event
public Page()
{
InitializeComponent();
Application.Current.Host.Content.FullScreenChanged += new EventHandler(Content_FullScreenChanged);
}
Silverlight mouse envent process
private void Rectangle_MouseMove(object sender, MouseEventArgs e)
{
Point p = e.GetPosition(e.Source as FrameworkElement); //get the position
Status.Text = String.Format("坐标位置({0}:{1})",p.X,p.Y);
}
private void ParentCanvas_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
String msg = "x:y = " + e.GetPosition(sender as FrameworkElement).ToString();
msg += " from " + (e.Source as FrameworkElement).Name;
Status.Text = msg;
}
void OnMouseUp(object sender, MouseButtonEventArgs e)
{
FrameworkElement element = sender as FrameworkElement;
trackingMouseMove = false;
element.ReleaseMouseCapture();
mousePosition.X = mousePosition.Y = 0;
element.Cursor = null;
}
Silverlight style
//Application scope style which can be used through the application
//Apply style
Add property to customized control
为用户控件添加属性
简单的修改一下上面示例中的XAML文件,添加一个文本块控件,用它来显示文字提示信息。
Margin="50 20 0 0"/>
Content="OK" Margin="10 0 0 0" FontSize="18"/>
Content="Cancel" Margin="50 0 0 0" FontSize="18"/>
定义属性:
public partial class ConfirmBox : UserControl
{
public ConfirmBox()
{
InitializeComponent();
}
public String Message
{
get { return this.message.Text; }
set { this.message.Text = value; }
}
}
在页面使用用户控件的属性,XAML编辑器能够识别出属性并提示:
TerryLee_Silverlight2_0052
为ConfirmBox控件的Message属性赋值:
No comments:
Post a Comment