private void btnMoveRight_Loaded(object sender, RoutedEventArgs e) { //take screenshot Grid grd = new Grid(); grd.Background = (ImageBrush)this.FindResource("HeaderBrush"); int height = 100; grd.Height = height; grd.Width = tabsGrid.ActualWidth; tabsGrid.Children.Add(grd); grd.Measure(new Size(tabsGrid.ActualWidth, height)); Size size = grd.DesiredSize; grd.Arrange(new Rect(new Point(0, 0), size)); byte[] img = TextureUtil.TakeScreenShot(tabsGrid, (int)tabsGrid.ActualWidth, (int)tabsGrid.ActualHeight); //crop image Point p = btnMoveRight.TranslatePoint(new Point(0, 0), mainGrid); img = TextureUtil.CropImageFile(img, 80, height - 2, (int)p.X, 0); //create brush BitmapImage bmImage = new BitmapImage(); bmImage.BeginInit(); bmImage.StreamSource = new MemoryStream(img); bmImage.CreateOptions = BitmapCreateOptions.None; bmImage.CacheOption = BitmapCacheOption.Default; bmImage.EndInit(); btnMoveRight.Background = new ImageBrush(bmImage); tabsGrid.Children.Remove(grd); }