I'm currently playing with wpf for the first time and I'm coming into some issues. I cannot figure out how to reference the wpf label element. I changed my label name to "label1" and try referencing it in my c# code, but alas no result just errors such as.
xaml
<Controls:MetroWindow x:Class="Rustomatic.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Rustomatic"
Height="350"
Width="525" >
<Grid>
<Label x:Name="label1" Content="Label" HorizontalAlignment="Left" Margin="229,128,0,0" VerticalAlignment="Top"/>
</Grid>
<Window.InputBindings>
<KeyBinding Gesture="F5" Command="{Binding Hit}" />
</Window.InputBindings>
c#
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using MahApps.Metro.Controls;
namespace Rustomatic
{
public partial class MainWindow : MetroWindow
{
label1.content = "hi";
}
public class Hit
{
}
}
Please take it lightly I was an intermediate at C# once but I haven't used it in a couple of years.