# DPI and Scaling

> Fix scaling problems of TX Text Control .NET for WPF: blurry icons in your own buttons, a ResourceProvider call that throws, and zoom values out of range.

- **Product:** TX Text Control .NET for WPF
- **Section:** Documentation
- **Kind:** Topic
- **Path:** TX Text Control .NET for WPF > Troubleshooting > DPI and Scaling
- **973 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/troubleshooting/dpi-scaling/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/troubleshooting/dpi-scaling/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/troubleshooting/dpi-scaling/llms-full.txt

---

On a display with a scale factor above 100%, images that were made for 96 dpi and stretched by Windows look blurry. The document, the rulers, the status bar and the ribbon tabs of TX Text Control scale with the display, but icons you take for your own buttons and menus need the right resolution. The few problems that Text Control documents for WPF are below. [DPI and Display Scaling](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/integration/dpi-scaling/llms-full.txt) describes scaling in a new application.

### Icons in Your Own Buttons Are Blurry

Buttons or menu items of your own that show icons of TX Text Control look blurry or too small on a display with a high resolution.

An image made for 96 dpi is stretched on a display with a higher resolution, which makes it blurry. [ResourceProvider](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/resourceprovider/llms-full.txt) returns the icons of TX Text Control in the size a resolution needs.

1. In the `Loaded` event of the window, request the icon with [GetLargeIcon](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/resourceprovider/getlargeicon-method/llms-full.txt) or [GetSmallIcon](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/resourceprovider/getsmallicon-method/llms-full.txt), passing the window or the resolution of its display.
2. Assign the returned image to your button or menu item.

[Give Your Own Buttons Sharp Icons](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/integration/dpi-scaling/#give-your-own-buttons-sharp-icons) shows the code that passes the window. Code that passes the resolution reads it from the window, as the example of the reference does; `printImage` is an `Image` element in *MainWindow.xaml*:

```csharp
using System.Windows;
using System.Windows.Controls;
using TXTextControl.WPF;

private void Window_Loaded(object sender, RoutedEventArgs e)
{
    // The resolution of the display the window is shown on
    double dpi = PresentationSource.FromVisual(this).CompositionTarget
        .TransformToDevice.Transform(new Point(96.0, 96.0)).X;

    printImage.Source = ResourceProvider.GetLargeIcon(
        ResourceProvider.FileMenuItem.TXITEM_Print.ToString(), dpi);
}
```

### GetLargeIcon or GetSmallIcon Throws an Exception

A call of `GetLargeIcon` or `GetSmallIcon` with a `FrameworkElement` throws an exception with this message:

```text
The specified framework element has not been loaded for presentation.
```

The size of the icon depends on the display the element is shown on, and the element isn't loaded yet.

1. Call the method in the `Loaded` event of the window or the element.
2. Or pass the resolution in dpi instead of the element, as the previous section shows.

### The Zoom Factor Can't Be Set

A value you set for [ZoomFactor](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/textcontrol/zoomfactor-property/llms-full.txt), or pass to [Zoom](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/textcontrol/zoom-method/llms-full.txt), isn't applied.

The zoom factor must be between 10 and 400 percent, and between 10 and 65535 percent when the [ViewMode](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/textcontrol/viewmode-property/llms-full.txt) is `PageView` or `Normal`.

1. Keep the value within the range of the current view mode, or switch to `PageView` for larger values.

### Related Pages

- [DPI and Display Scaling](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/integration/dpi-scaling/llms-full.txt): scaling in a new application.
- [Viewing, Zooming, and Navigation](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/document-editor/viewing/llms-full.txt): zoom and view modes.
- [Control Initialization](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/troubleshooting/initialization/llms-full.txt): code that runs before the control is ready.

---

## Nearby

- **Previous:** [Fonts and Document Layout](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/troubleshooting/fonts/llms-full.txt)
- **Next:** [Printing](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/troubleshooting/printing/llms-full.txt)
