private void DisplaySpectrogram() { //Display Settings double brightness = sliderBrightness.Value; double specGridWidth = this.ActualWidth - ControlsGrid.ActualWidth; specGridWidth = specGridWidth < 0 ? 0 : specGridWidth; ScrollBar scrollBar = (ScrollBar)scrollViewerSpec.Template.FindName("PART_VerticalScrollBar", scrollViewerSpec); double scrollBarSpace = scrollBar.ActualWidth * 2 + scrollViewerSpec.Margin.Left; SpecGrid.MaxWidth = specGridWidth; spec.SetFixedWidth((int)((specGridWidth - scrollBarSpace))); BitmapSource source = spec.GetBitmapSource(brightness, dB: false, roll: false); TransformedBitmap trans = new TransformedBitmap(source, new ScaleTransform(zoomFactor, zoomFactor)); imageSpec.Source = trans; }