I want to create a WPF with 2 simple buttons. In the IDE, it shows how the buttons will be displayed at runtime, exept that the runtime version is completely blank. I don't know how to fix that, and i'm growing pretty tired of it. Here is my MainWindow.xaml :
<Window x:Class="WpfApp3.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApp3"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="25"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid Background="#2e5eaa"
Grid.ColumnSpan="2">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock Text="8M6B"
Foreground="White"
Grid.Column="1"
VerticalAlignment="Center"
HorizontalAlignment="Center"
FontWeight="Medium"/>
<Button
Content="Site web"
Foreground="White"
Grid.Column="2"
Background="Transparent"
VerticalAlignment="Center"
HorizontalAlignment="Center"
FontWeight="Light"
>
</Button>
</Grid>
<StackPanel Grid.Row="1">
<StackPanel Orientation="Horizontal" >
<!--<Image Width="70" Height="70" Source="img/86noice.png"
Margin="10,10,0,0"/>-->
<TextBlock Text="8M6B"
Foreground="White"
FontSize="20"
FontWeight="Medium"
VerticalAlignment="Center"/>
</StackPanel>
<TextBlock Text="Bonjour et bienvenue sur 8 Morts 6 Blesses !"
Foreground="White"
FontSize="25"
FontWeight="Medium"
HorizontalAlignment="Center"/>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="180">
<Button x:Name="BtnConnect" Content="Se connecter"
Foreground="White"
FontSize="14"
FontWeight="Medium" Height="37" Width="137"
Background="#222222"
Margin="0,0,20,0">
<Button.Resources>
<Style TargetType="Border">
<Setter Property="CornerRadius" Value="12"/>
</Style>
</Button.Resources>
</Button>
<Button Content="S'inscrire"
Click="btnFatInscription_Click"
Foreground="White"
FontSize="14"
FontWeight="Medium" Height="37" Width="138"
Background="#FF934F"
Margin="20,0,0,0">
<Button.Resources>
<Style TargetType="{x:Type Border}">
<Setter Property="CornerRadius" Value="12"/>
</Style>
</Button.Resources>
</Button>
</StackPanel>
</StackPanel>
</Grid>
</Window>
MainWindow.xaml.cs :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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;
namespace WpfApp3
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
}
}
And the preview in Visual Studio 2022 :

An here is the actual WPF window that opens at runtime
CodePudding user response:
You have attached an event to your button:
Click="btnFatInscription_Click"
But this event does not exist in your code behind.

