2
votes

I am building a UWP app. I was writing a control to make a Textbox look like a Textblock until clicked. So, I inherited my class from the Textbox class but I am having some issues. Here is the code I wrote through some reference.

public class EditableTextBox:TextBox
    {
        public EditableTextBox()
        {
            this.BorderBrush = new SolidColorBrush(Colors.Black);
        }

        protected override void OnTapped(TappedRoutedEventArgs e)
        {
            this.IsReadOnly = false;
            SetEditingStyle();
            base.OnTapped(e);
        }

        protected override void OnDoubleTapped(DoubleTappedRoutedEventArgs e)
        {
            this.IsReadOnly = false;
            SetEditingStyle();
            base.OnDoubleTapped(e);
        }

        protected override void OnLostFocus(RoutedEventArgs e)
        {
            this.IsReadOnly = true;
            SetReadonlyStyle();
            base.OnLostFocus(e);
        }

        public void SetReadonlyStyle()
        {
            this.BorderBrush.Opacity = 0;
            this.Background.Opacity = 0;
        }

        public void SetEditingStyle()
        {
            this.BorderBrush.Opacity = 1;
            this.Background.Opacity = 1;
        }
    }

The compiler asked me to Reference System.Runtime as shown below:

The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

Predefined type 'System.Void' is not defined or imported

The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

What can I do to solve this?

1
Have you tried to refresh your Nuget packages? Especially Microsoft.NETCore? - Romasz

1 Answers

2
votes

Right-click on the solution in the Solution Explorer window and select the 'Restore NuGet packages for solution' option.

This will download the required NuGet packages for your project.