I’m just learning visual studio and already struggling. I can’t add WindowsBase.dll as a reference because I get an error that its automatically being referenced by the build system. But without adding it, I get an error, “Cannot find type System.Windows.DependencyObject in module WindowsBase.dll. What am I missing?
Below is my code, it’s a copy from windows tutorial on writing a uwp app.
using System;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Media;
using Windows.UI;
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409
namespace SayHello
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class MainPage : Page
{
private Random rand;
public MainPage()
{
this.InitializeComponent();
rand = new Random();
}
private byte[] GetRandomBytes(int n)
{
var randomBytes = new byte[n];
rand.NextBytes(randomBytes);
return randomBytes;
}
private void SayHelloButton_Click(object sender, RoutedEventArgs e)
{
byte[] rgb = GetRandomBytes(3);
var randomColorBrush = new SolidColorBrush(Color.FromArgb(255, rgb[0], rgb[1], rgb[2]));
textBox1.BorderBrush = randomColorBrush;
textBox1.Foreground = randomColorBrush;
}
}
}