Just tried a GUI code and at first I could see text, buttons after first compile. Then I tried to hook up the buttons to the RadioButton, after compiling this all I was able to see was plain white.
The .xaml code:
<Window x:Class="GUItest.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:GUItest"
mc:Ignorable="d"
Title="MainWindow" Height="855" Width="1628">
<Grid RenderTransformOrigin="0.500,0.525" Margin="0,0,0,-6">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0*"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid>
<TextBlock HorizontalAlignment="Left" Margin="387,60,0,0" TextWrapping="Wrap" Text="Select an option:" VerticalAlignment="Top" Width="76"/>
</Grid>
<Grid>
<TextBlock HorizontalAlignment="Left" Margin="10,305,0,0" TextWrapping="Wrap" Text="Select an option:" VerticalAlignment="Top" Height="150" Width="237" RenderTransformOrigin="0.476,0.498"/>
<RadioButton x:Name="ABC" Content="ABC" HorizontalAlignment="Left" Margin="297,161,0,0" VerticalAlignment="Top"/>
<RadioButton x:Name="DEF" Content="DEF" HorizontalAlignment="Left" Margin="488,161,0,0" VerticalAlignment="Top"/>
</Grid>
<Grid>
<RadioButton x:Name="ABCButton" Content="ABC" IsChecked="True" HorizontalAlignment="Left" Margin="297,161,0,0" VerticalAlignment="Top"/>
<RadioButton x:Name="DEFButton" Content="DEF" HorizontalAlignment="Left" Margin="488,161,0,0" VerticalAlignment="Top"/>
<TextBlock HorizontalAlignment="Left" Margin="0,0,0,0" TextWrapping="Wrap" Text="Select an option:" VerticalAlignment="Top" Width="238" Height="143" RenderTransformOrigin="0.50-53,0.501">
<TextBlock.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform AngleX="-0.1"/>
<RotateTransform/>
<TranslateTransform X="-0.332"/>
</TransformGroup>
</TextBlock.RenderTransform>
</TextBlock>
</Grid>
</Grid>
</Window>
And this is the .xaml.cs code:
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 GUItest
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
if (ABCButton.IsChecked == true)
{
MessageBox.Show("ABC");
}
else if (DEFButton.IsChecked == true)
{
MessageBox.Show("DEF");
}
}
}
}
This is just made by me to better understand the GUI.
All of your items fall in the first column and your ColumnWidth of the first one is 0*. This means that the width will be 0 (times) x, which results in a width of 0.
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0*"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
Try to make this * or 2* or something, or place the items in a different column. Good luck.
Edit:
Placing the items in a different column can be done by:
<Grid Grid.Column="1">
<TextBlock HorizontalAlignment="Left" Margin="387,60,0,0" TextWrapping="Wrap" Text="Select an option:" VerticalAlignment="Top" Width="76"/>
</Grid>
<Grid Grid.Column="1"> <!-- Here the 1 means place this grid in the first column of the main grid -->
<TextBlock HorizontalAlignment="Left" Margin="10,305,0,0" TextWrapping="Wrap" Text="Select an option:" VerticalAlignment="Top" Height="150" Width="237" RenderTransformOrigin="0.476,0.498"/>
<RadioButton x:Name="ABC" Content="ABC" HorizontalAlignment="Left" Margin="297,161,0,0" VerticalAlignment="Top"/>
<RadioButton x:Name="DEF" Content="DEF" HorizontalAlignment="Left" Margin="488,161,0,0" VerticalAlignment="Top"/>
</Grid>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.