
在MVVM的架構下,通常為了將事件及邏輯從View的code behind(.cs檔)中搬離,會使用到Command,不過Command的建置作業比傳統的事件較為麻煩,在參考Blend 的WPF資料繫結應用程式專案及Google之後,發現不需使用Command而且還能跟原本的事件相容,並且搬移到ViewModel中!
(1) 在Xaml中, ListView新增SelectionChanged事件
小賢 發表在 痞客邦 留言(0) 人氣(1,075)
初始化
Car car = new Car();
car.root = new Root();
car.root.list = new List();
car.root.name = "海德格";
car.root.data = "救我";
for (int f = 0; f < 10; f++)
{
car.root.list.Add(f.ToString());
}
小賢 發表在 痞客邦 留言(0) 人氣(1,852)

private void button2_Click(object sender, RoutedEventArgs e)
{
WriteableBitmap writeableBitmap = new WriteableBitmap(bitmapImage);
int startTime = Environment.TickCount;
int width = bitmapImage.PixelWidth;
int height = bitmapImage.PixelHeight;
int stride = width * ((bitmapImage.Format.BitsPerPixel + 7) / 8);
byte[] pixel = new byte[height * stride];
writeableBitmap.CopyPixels(pixel, stride, 0);
Parallel.For(0, height, y =>
{
int x;
for (x = 0; x < stride; x++)
{
pixel[x + y * stride] = (byte)(255 - pixel[x + y * stride]);
}
});
writeableBitmap.WritePixels(new Int32Rect(0, 0, width, height), pixel, stride, 0);
image1.Source = writeableBitmap;
this.Title =(Environment.TickCount - startTime) + " ms";
//CroppedBitmap
}
小賢 發表在 痞客邦 留言(1) 人氣(4,514)