ProfK
ProfK

Reputation: 51084

Why are my buttons not visible in the XAML designer?

I have the following dead standard (no funny includes or anything):

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="50" />
        <RowDefinition Height="50" />
        <RowDefinition Height="6" />
        <RowDefinition Height="94"/>
        <RowDefinition />
    </Grid.RowDefinitions>
    <Grid Grid.Row="0" VerticalAlignment="Center" Margin="0,5" >
        <DockPanel LastChildFill="True" Margin="0,5" VerticalAlignment="Center">
            <Label Margin="2" Content="Last Message:"/>
            <TextBox IsReadOnly="True" Text="{Binding SchedulerStatus, Mode=OneWay}" DockPanel.Dock="Left" Height="30" VerticalContentAlignment="Center" Margin="0, 0, 10, 0" />
        </DockPanel>
    </Grid>
    <StackPanel Grid.Row="1"></StackPanel>
    <StackPanel x:Name="ButtonPanel" Grid.Row="2" Orientation="Horizontal" Height="100" HorizontalAlignment="Stretch" Tag="Command" >
        <Button x:Name="Start" IsEnabled="True" Command="{Binding StartCommand}" Content="Start Service" Height="50" Margin="20, 10, 10, 10" Width="95" Tag="Command" />
        <Button x:Name="Pause"  IsEnabled="True" Content="Pause Service" Height="50" Margin="10" Width="95" Tag="Command" />
        <Button x:Name="Stop" IsEnabled="True" Command="{Binding StopCommand}" Content="Stop Service" Height="50" Margin="10" Width="95" Tag="Command"  />
        <Button x:Name="Process" IsEnabled="True" Content="Force Processing" Height="50" Margin="10" Width="95" Tag="Command"  />
        <Button x:Name="Config" IsEnabled="True" Content="Configuration" Height="50" Margin="10" Width="95" Tag="Command"  />
    </StackPanel>
</Grid>

Yet none of the buttons are visible. If I make Grid.Row="1", I can see half button outlines, as row 1 is not as higher as row 2. If I hover my mouse over the buttons row, I can see the outline of each button as I hover, but under ops normal, all the buttons are invisible. The buttons are also invisible at runtime.

Upvotes: 0

Views: 743

Answers (2)

Joy
Joy

Reputation: 157

you remove height and width from ButtonPanel.then button are visible. code is :-

<Window x:Class="Demo_wpf.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="600" Width="600">
<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="50" />
        <RowDefinition Height="50" />
        <RowDefinition Height="100" />
        <RowDefinition Height="94"/>
        <RowDefinition />
    </Grid.RowDefinitions>
    <Grid Grid.Row="0" VerticalAlignment="Center" Margin="0,5" >
        <DockPanel LastChildFill="True" Margin="0,5" VerticalAlignment="Center">
            <Label Margin="2" Content="Last Message:"/>
            <TextBox IsReadOnly="True" Text="{Binding SchedulerStatus, Mode=OneWay}" DockPanel.Dock="Left" Height="30" VerticalContentAlignment="Center" Margin="0, 0, 10, 0" />
        </DockPanel>
    </Grid>
    <StackPanel Grid.Row="1"></StackPanel>
    <StackPanel x:Name="ButtonPanel" Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Stretch" Tag="Command" >
        <Button x:Name="Start" IsEnabled="True" Command="{Binding StartCommand}" Content="Start Service" Height="50" Margin="20, 10, 10, 10" Width="95" Tag="Command" />
        <Button x:Name="Pause"  IsEnabled="True" Content="Pause Service" Height="50" Margin="10" Width="95" Tag="Command" />
        <Button x:Name="Stop" IsEnabled="True" Command="{Binding StopCommand}" Content="Stop Service" Height="50" Margin="10" Width="95" Tag="Command"  />
        <Button x:Name="Process" IsEnabled="True" Content="Force Processing" Height="50" Margin="10" Width="95" Tag="Command"  />
        <Button x:Name="Config" IsEnabled="True" Content="Configuration" Height="50" Margin="10" Width="95" Tag="Command"  />
    </StackPanel>
</Grid>

Upvotes: 0

Dhru &#39;soni
Dhru &#39;soni

Reputation: 1058

I done some modification in rowdefinitions check that

<Window x:Class="Demo.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto"/>
            <RowDefinition />
        </Grid.RowDefinitions>
        <Grid Grid.Row="0" VerticalAlignment="Center" Margin="0,5" >
            <DockPanel LastChildFill="True" Margin="0,5" VerticalAlignment="Center">
                <Label Margin="2" Content="Last Message:"/>
                <TextBox IsReadOnly="True" Text="{Binding SchedulerStatus, Mode=OneWay}" DockPanel.Dock="Left" Height="30" VerticalContentAlignment="Center" Margin="0, 0, 10, 0" />
            </DockPanel>
        </Grid>
        <StackPanel Grid.Row="1"></StackPanel>
        <StackPanel x:Name="ButtonPanel" Grid.Row="2" Orientation="Horizontal" Height="100" HorizontalAlignment="Stretch" Tag="Command" >
            <Button x:Name="Start" IsEnabled="True" Command="{Binding StartCommand}" Content="Start Service" Height="50" Margin="20, 10, 10, 10" Width="95" Tag="Command" />
            <Button x:Name="Pause"  IsEnabled="True" Content="Pause Service" Height="50" Margin="10" Width="95" Tag="Command" />
            <Button x:Name="Stop" IsEnabled="True" Command="{Binding StopCommand}" Content="Stop Service" Height="50" Margin="10" Width="95" Tag="Command"  />
            <Button x:Name="Process" IsEnabled="True" Content="Force Processing" Height="50" Margin="10" Width="95" Tag="Command"  />
            <Button x:Name="Config" IsEnabled="True" Content="Configuration" Height="50" Margin="10" Width="95" Tag="Command"  />
        </StackPanel>
    </Grid>
</Window>

Upvotes: 1

Related Questions