Saturday, November 7, 2009

一步一步学Silverlight 2系列(7):全屏模式支持 - TerryLee's Tech Space - 博客园

一步一步学Silverlight 2系列(7):全屏模式支持 - TerryLee's Tech Space - 博客园: "private void toggleButton_Click(object sender, RoutedEventArgs e) { Content contentObject = Application.Current.Host.Content; contentObject.IsFullScreen = !contentObject.IsFullScreen; }"

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文件,添加一个文本块控件,用它来显示文字提示信息。


Opacity="0.7" Fill="#FF8A8A8A"/>









HorizontalAlignment="Left" VerticalAlignment="Center"
Margin="50 20 0 0"/>


No comments: