ellipse1.Fill =new SolidColorBrush( Colors.Black) 颜色填充
图片加载Uri uri = new Uri("img/1.jpg", UriKind.RelativeOrAbsolute);BitmapImage img = new BitmapImage(uri);
直接创建xaml using System.Text;using System.Windows.Markup;StringBuilder sb = new StringBuilder();sb.Append("<Textblock>");sb.Append("xmlns=/"http://schemas.microsoft.com/client/2007/"");sb.Append("Canvas.Left........../>");TextBlock tb = new TextBlock();tb = (TextBlock)XamlReader.Load(sb.ToString());
线程问题newthread = new Thread(new ThreadStart(mm));newthread.Start();
void mm() { int i = 60; while (i > 0) { tb1.Dispatcher.BeginInvoke(delegate() { tb1.Text = i.ToString(); }); if (i == 0) { newthread.Abort(); newthread.Join(); return; } i--; Thread.Sleep(1000);
}
}
定时器 DispatcherTimer timer = new DispatcherTimer(); //设置间隔1秒 timer.Interval = new TimeSpan(0, 0, 1); //创建事件处理 timer.Tick += new EventHandler(timer_Tick); //开始计时 timer.Start();void timer_Tick(object sender, EventArgs e) { //输出时间 tb1.Text = "当前时间:" + DateTime.Now.ToLongTimeString(); }
全屏模式using System.Windows.Interop; Content obj = Application.Current.Host.Content; obj.IsFullScreen = true;
FrameworkElement s = sender as FrameworkElement; s.ReleaseMouseCapture();停址鼠标 s.CaptureMouse(); 捕捉鼠标
控件外边界button1.Margin = new Thickness(4);
文件操作using System.IO.IsolatedStorage; spath = "tablea.txt"; spath = System.IO.Path.Combine(spath);void savefile(string savepath, string content) { IsolatedStorageFile storefile = IsolatedStorageFile.GetUserStoreForApplication(); IsolatedStorageFileStream sf = storefile.CreateFile(savepath); using (StreamWriter sw = new StreamWriter(sf)) { sw.WriteLine(content); } sf.Close(); } void loadfile(string readpath) { string content = string.Empty; using (IsolatedStorageFile storefile = IsolatedStorageFile.GetUserStoreForApplication()) { if (storefile.FileExists(readpath)) { StreamReader sr = new StreamReader(storefile.OpenFile(readpath, FileMode.Open, FileAccess.Read)); content = sr.ReadToEnd(); } } } void deletefile(string path) { using (IsolatedStorageFile storefile = IsolatedStorageFile.GetUserStoreForApplication()) { storefile.DeleteFile(path); } }