This is a migrated thread and some comments may be shown as answers.

RadButton not visible on Project Load

1 Answer 128 Views
Buttons
This is a migrated thread and some comments may be shown as answers.
Matthew
Top achievements
Rank 1
Matthew asked on 08 Mar 2021, 11:07 AM
When this project is loaded in debug mode the RadButton is not visible, however if I Comment out the code for the button during debug, save it, uncomment the code and save again - T
<Window x:Class="ButtonsDisappear.MainWindow"
        Title="MainWindow"
        Height="600"
        Width="800"
        WindowState="Maximized">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="35"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="35"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <Grid Grid.Row="2" Grid.Column="0">
            <Grid.RowDefinitions>
                <RowDefinition x:Name="gridRow2" Height="*"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition x:Name="gridColumn0" Width="*"/>
                <ColumnDefinition x:Name="gridColumn1" Width="*"/>
            </Grid.ColumnDefinitions>
            <telerik:RadButton Grid.Row="0" Grid.Column="0"
                           x:Name="radButton"
                           Content="Test Button"
                           HorizontalAlignment="Center"
                           VerticalAlignment="Center"
                           Width="{Binding ElementName=gridColumn0, Path=ActualWidth}"
                           Height="{Binding ElementName=gridRow2, Path=ActualHeight}" 
                           Click="radButton_Click"/>
        </Grid>
    </Grid>
</Window>

 

using System.Windows;
using Telerik.Windows.Controls;
 
namespace ButtonsDisappear
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }
        private void radButton_Click(object sender, RoutedEventArgs e)
        {
            RadButton b = (RadButton)sender;
        }
    }
}
he button becomes visible...

1 Answer, 1 is accepted

Sort by
0
Matthew
Top achievements
Rank 1
answered on 08 Mar 2021, 01:33 PM

Problem resolved - issue is that ActualHeight/ActualWidth are not calculated  until page and controls are loaded... 

 

https://stackoverflow.com/questions/1695101/why-are-actualwidth-and-actualheight-0-0-in-this-case

Tags
Buttons
Asked by
Matthew
Top achievements
Rank 1
Answers by
Matthew
Top achievements
Rank 1
Share this question
or