0

I keep getting an error: visualtreehelper' does not contain a definition for 'getdpi' also this is a open source https://github.com/IntelOrca/teds-terminal i really want it to work Please help me. Code:

using System;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Interop;
using System.Windows.Media;
using MahApps.Metro.Controls;
using tterm.Ui;
using tterm.Extensions;
using tterm.Utility;
using tterm.Terminal;
using Newtonsoft.Json;
using static tterm.Native.Win32;

namespace tterm
{
    public class EnhancedWindow : MetroWindow
    {
        private readonly WindowInteropHelper _interopHelper;

        protected bool IsResizing { get; private set; }
        protected IntPtr Hwnd => _interopHelper.Handle;
        protected DpiScale Dpi => VisualTreeHelper.GetDpi(this);

        public Size Size
        {
            get => RenderSize;
            set
            {
                if (value != RenderSize)
                {
                    var dpi = Dpi;
                    int width = (int)(value.Width * dpi.DpiScaleX);
                    int height = (int)(value.Height * dpi.DpiScaleY);
                    uint flags = SWP_NOMOVE | SWP_NOZORDER;
                    SetWindowPos(Hwnd, IntPtr.Zero, 0, 0, width, height, flags);
                }
            }
        }
    }
}
thatguy
  • 21,059
  • 6
  • 30
  • 40
DexLite
  • 13
  • 1
  • Which .NET version do you target? See [VisualTreeHelper.GetDpi](https://learn.microsoft.com/en-us/dotnet/api/system.windows.media.visualtreehelper.getdpi) for a list of targets supporting this method. – Klaus Gütter Jul 11 '20 at 09:26
  • WPF? Add the tag `wpf` then. – aepot Jul 11 '20 at 11:08
  • The project in the linked repository uses .NET Framework 4.6.2 which supports `VisualTreeHelper.GetDpi`. Do you have this version of the framework installed? – thatguy Jul 11 '20 at 15:48

0 Answers0