C# 为什么可以';我没看见什么吗?

C# 为什么可以';我没看见什么吗?,c#,C#,刚试过一个GUI代码,一开始我可以在第一次编译后看到文本和按钮。然后我试着把按钮连接到单选按钮上,编译完后我能看到的只有纯白 .xaml代码: 这是.xaml.cs代码: 使用系统; 使用System.Collections.Generic; 使用System.Linq; 使用系统文本; 使用System.Threading.Tasks; 使用System.Windows; 使用System.Windows.Controls; 使用System.Windows.Data; 使用System.

刚试过一个GUI代码,一开始我可以在第一次编译后看到文本和按钮。然后我试着把按钮连接到单选按钮上,编译完后我能看到的只有纯白

.xaml代码:


这是.xaml.cs代码:

使用系统;
使用System.Collections.Generic;
使用System.Linq;
使用系统文本;
使用System.Threading.Tasks;
使用System.Windows;
使用System.Windows.Controls;
使用System.Windows.Data;
使用System.Windows.Documents;
使用System.Windows.Input;
使用System.Windows.Media;
使用System.Windows.Media.Imaging;
使用System.Windows.Navigation;
使用System.Windows.Shapes;
命名空间吉他测试
{
/// 
///MainWindow.xaml的交互逻辑
/// 
公共部分类主窗口:窗口
{
公共主窗口()
{
初始化组件();
}
私有无效按钮\u单击(对象发送者,路由目标e)
{
如果(ABCButton.IsChecked==true)
{
MessageBox.Show(“ABC”);
}
else if(deffbutton.IsChecked==true)
{
MessageBox.Show(“DEF”);
}
}
}
}

这是我为了更好地理解GUI而做的。

您的所有项目都位于第一列,第一列的列宽为0*。这意味着宽度将为0(乘以)x,这将导致宽度为0

    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="0*"/>
        <ColumnDefinition/>
    </Grid.ColumnDefinitions>

试着用这个*或2*或别的什么,或者把项目放在不同的列中。 祝你好运

编辑:

可以通过以下方式将项目放置在不同的列中:

    <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>

所有项目都位于第一列,第一列的列宽为0*。这意味着宽度将为0(乘以)x,这将导致宽度为0

    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="0*"/>
        <ColumnDefinition/>
    </Grid.ColumnDefinitions>

试着用这个*或2*或别的什么,或者把项目放在不同的列中。 祝你好运

编辑:

可以通过以下方式将项目放置在不同的列中:

    <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>


请阅读,特别是标题为“编写一个总结特定问题的标题”的部分。欢迎阅读堆栈溢出!最好不要认为这里的人很粗鲁。这种类型的评论不属于问题,因此我将其相应删除。请阅读,特别是标题为“编写一个总结特定问题的标题”的部分。欢迎使用堆栈溢出!最好不要认为这里的人很粗鲁。这种类型的评论不属于问题,因此我相应地删除了它。