locked
GUI Only Show Up At Design Time

    Question

  • I am developing a Universal app for windows 8.1 and Windows Phone 8.1.  I have developed a user control and I placed it on both the design surface in Windows and Windows phone.  At design time everything is good to go.  At run time I only get a big X on the screen.  Just for testing I also put a button on each design surface to see if it was my user control, but even the button did not show up.  I've tried searching for this and I can't find anything remotely revelent.

    I'm guessing it has something to do with my user control, but since there are no compile errors and it shows up just fine at desgin time, I have no idea what to do next.  Very frustrating.


    Larry Maturo


    • Edited by lmaturo Tuesday, November 18, 2014 10:31 PM
    Tuesday, November 18, 2014 10:29 PM

Answers

  • Well, I fixed the problem.  I created a new project and added the two controls to the new project and it worked.  Go figure.

    Larry Maturo

    • Marked as answer by lmaturo Saturday, November 22, 2014 7:14 PM
    Saturday, November 22, 2014 7:14 PM

All replies

  • would you please post xaml code ?

    在現實生活中,你和誰在一起的確很重要,甚至能改變你的成長軌跡,決定你的人生成敗。 和什麼樣的人在一起,就會有什麼樣的人生。 和勤奮的人在一起,你不會懶惰; 和積極的人在一起,你不會消沈; 與智者同行,你會不同凡響; 與高人為伍,你能登上巔峰。


    Wednesday, November 19, 2014 3:25 AM
  • Hi Larry,

    If you can see the user control from the design surface, it should also display in the runtime. However i'm not quite understand what is big X means, something like the image broken? Any screenshot also XAML code is welcome.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Wednesday, November 19, 2014 5:51 AM
    Moderator
  • Hi James,

    The x is all that shows up on the screen when you debug the app.  It's the same thing you get when you debug a new app you haven't done anything to.

    This is the XAML (for the Windows Phone 8.1:

     
        <Grid>
            <CustomControls:GameBoard HorizontalAlignment="Left" Margin="10,91,0,0" VerticalAlignment="Top" Height="539"/>
        </Grid>
    


    Larry Maturo

    Wednesday, November 19, 2014 11:38 PM
  • Hello Larry,

    Do you mean something like this?

    I cannot reproduce the problem you are facing, I don't know what's inside your user control, if there is only some buttons and not important things, could you share the project with us? Thanks.

    I create a usercontrol and put 3 buttons inside, I can see the thing in design surface also in runtime.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Thursday, November 20, 2014 7:21 AM
    Moderator
  • Hi James,

    Yes, exactly like that.  I basically have a button based user control embedded in a grid based user control.  I'm creating a bingo game.  The button turns a filled in circle on and off when you press it.  It's nothing complicated at all, which is what is puzzling.  Below is the xaml for the button, and below that is the xaml for the grid.  Below that is the C# code behind for the button. The grid has no code behind as intending to use MVVM.

    -- Larry

        <Border BorderBrush="Black" BorderThickness="3">
            <Button x:Name="BingoBtn" Background="Moccasin" Height="100" Width="100" Click="BingoBtn_Click">
                    <StackPanel Orientation="Vertical"  Width="100" Height="100">
                        <TextBlock x:Name="BingoText" HorizontalAlignment="Center" VerticalAlignment="Top" Foreground="Black" Width="50"  Height="50" FontSize="32" FontWeight="Bold"/>
                        <Ellipse x:Name="Chip" Width="25" Height="25" Fill="Red" HorizontalAlignment="Left" VerticalAlignment="Bottom"  Stroke="Black" StrokeThickness="3" Margin="0,-15,0,0"/>
                    </StackPanel>
            </Button>
        </Border>
    
        <Border BorderBrush="Black" BorderThickness="3" HorizontalAlignment="Left" VerticalAlignment="Top">
            <Grid Background="Moccasin" HorizontalAlignment="Left" VerticalAlignment="Top">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition/>
                    <ColumnDefinition/>
                    <ColumnDefinition/>
                    <ColumnDefinition/>
                    <ColumnDefinition/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition/>
                    <RowDefinition/>
                    <RowDefinition/>
                    <RowDefinition/>
                    <RowDefinition/>
                    <RowDefinition/>
                </Grid.RowDefinitions>
                <Border Grid.Row="0" Grid.Column="0"  BorderBrush="Black" BorderThickness="3">
                    <TextBlock Grid.Row="0" Grid.Column="0" Text="B" FontFamily="Georgia" FontWeight="Bold" FontSize="40" Foreground="Red" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                </Border>
                <Border Grid.Row="0" Grid.Column="1"  BorderBrush="Black" BorderThickness="3">
                    <TextBlock Grid.Row="0" Grid.Column="1" Text="I" FontFamily="Georgia" FontWeight="Bold" FontSize="40" Foreground="Green" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                </Border>
                <Border Grid.Row="0" Grid.Column="2"  BorderBrush="Black" BorderThickness="3">
                    <TextBlock Grid.Row="0" Grid.Column="2" Text="N" FontFamily="Georgia" FontWeight="Bold" FontSize="40" Foreground="Blue" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                </Border>
                <Border Grid.Row="0" Grid.Column="3"  BorderBrush="Black" BorderThickness="3">
                    <TextBlock Grid.Row="0" Grid.Column="3" Text="G" FontFamily="Georgia" FontWeight="Bold" FontSize="40" Foreground="Gold"  HorizontalAlignment="Center" VerticalAlignment="Center"/>
                </Border>
                <Border Grid.Row="0" Grid.Column="4"  BorderBrush="Black" BorderThickness="3">
                    <TextBlock Grid.Row="0" Grid.Column="4" Text="O" FontFamily="Georgia" FontWeight="Bold" FontSize="40" Foreground="Purple" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                </Border>
                <local:ValueOfASquare Grid.Row="1" Grid.Column="0" CheckedChanged="BingoBall_CheckedChanged" Text="{Binding Board[B1]}"/>
                <local:ValueOfASquare Grid.Row="1" Grid.Column="1" CheckedChanged="BingoBall_CheckedChanged" Text="{Binding Board[B2]}"/>
                <local:ValueOfASquare Grid.Row="1" Grid.Column="2" CheckedChanged="BingoBall_CheckedChanged" Text="{Binding Board[B3]}"/>
                <local:ValueOfASquare Grid.Row="1" Grid.Column="3" CheckedChanged="BingoBall_CheckedChanged" Text="{Binding Board[B4]}"/>
                <local:ValueOfASquare Grid.Row="1" Grid.Column="4" CheckedChanged="BingoBall_CheckedChanged" Text="{Binding Board[B5]}"/>
                <local:ValueOfASquare Grid.Row="2" Grid.Column="0" CheckedChanged="BingoBall_CheckedChanged" Text="{Binding Board[I1]}"/>
                <local:ValueOfASquare Grid.Row="2" Grid.Column="1" CheckedChanged="BingoBall_CheckedChanged" Text="{Binding Board[I2]}"/>
                <local:ValueOfASquare Grid.Row="2" Grid.Column="2" CheckedChanged="BingoBall_CheckedChanged" Text="{Binding Board[I3]}"/>
                <local:ValueOfASquare Grid.Row="2" Grid.Column="3" CheckedChanged="BingoBall_CheckedChanged" Text="{Binding Board[I4]}"/>
                <local:ValueOfASquare Grid.Row="2" Grid.Column="4" CheckedChanged="BingoBall_CheckedChanged" Text="{Binding Board[I5]}"/>
                <local:ValueOfASquare Grid.Row="3" Grid.Column="0" CheckedChanged="BingoBall_CheckedChanged" Text="{Binding Board[N1]}"/>
                <local:ValueOfASquare Grid.Row="3" Grid.Column="1" CheckedChanged="BingoBall_CheckedChanged" Text="{Binding Board[N2]}"/>
                <local:ValueOfASquare Grid.Row="3" Grid.Column="2" CheckedChanged="BingoBall_CheckedChanged" Text="{Binding Board[N3]}"/>
                <local:ValueOfASquare Grid.Row="3" Grid.Column="3" CheckedChanged="BingoBall_CheckedChanged" Text="{Binding Board[N4]}"/>
                <local:ValueOfASquare Grid.Row="3" Grid.Column="4" CheckedChanged="BingoBall_CheckedChanged" Text="{Binding Board[N5]}"/>
                <local:ValueOfASquare Grid.Row="4" Grid.Column="0" CheckedChanged="BingoBall_CheckedChanged" Text="{Binding Board[G1]}"/>
                <local:ValueOfASquare Grid.Row="4" Grid.Column="1" CheckedChanged="BingoBall_CheckedChanged" Text="{Binding Board[G2]}"/>
                <local:ValueOfASquare Grid.Row="4" Grid.Column="2" CheckedChanged="BingoBall_CheckedChanged" Text="{Binding Board[G3]}"/>
                <local:ValueOfASquare Grid.Row="4" Grid.Column="3" CheckedChanged="BingoBall_CheckedChanged" Text="{Binding Board[G4]}"/>
                <local:ValueOfASquare Grid.Row="4" Grid.Column="4" CheckedChanged="BingoBall_CheckedChanged" Text="{Binding Board[G5]}"/>
                <local:ValueOfASquare Grid.Row="5" Grid.Column="0" CheckedChanged="BingoBall_CheckedChanged" Text="{Binding Board[O1]}"/>
                <local:ValueOfASquare Grid.Row="5" Grid.Column="1" CheckedChanged="BingoBall_CheckedChanged" Text="{Binding Board[O2]}"/>
                <local:ValueOfASquare Grid.Row="5" Grid.Column="2" CheckedChanged="BingoBall_CheckedChanged" Text="{Binding Board[O3]}"/>
                <local:ValueOfASquare Grid.Row="5" Grid.Column="3" CheckedChanged="BingoBall_CheckedChanged" Text="{Binding Board[O4]}"/>
                <local:ValueOfASquare Grid.Row="5" Grid.Column="4" CheckedChanged="BingoBall_CheckedChanged" Text="{Binding Board[O5]}"/>
            </Grid>
        </Border>
    
            public ValueOfASquare()
            {
                this.InitializeComponent();
            }
    
            public ValueOfASquare(int p)
            {
                 this.Text = p.ToString();
            }
    
            // Using a DependencyProperty as the backing store for Checked.  This enables animation, styling, binding, etc...
            public static readonly DependencyProperty CheckedProperty =
                            DependencyProperty.Register("Checked", typeof(bool), typeof(ValueOfASquare), new PropertyMetadata(false));
            
            public bool Checked
            {
                get { return (bool)GetValue(CheckedProperty); }
                set { SetValue(CheckedProperty, value); }
            }
    
            // Using a DependencyProperty as the backing store for BingoText.  This enables animation, styling, binding, etc...
            public static readonly DependencyProperty TextProperty =
                            DependencyProperty.Register("Text", typeof(string), typeof(ValueOfASquare), new PropertyMetadata("B 1"));
    
    
            public string Text
            {
                get { return BingoText.Text; }
                set { OnPropertyChanged("Text"); }
            }
     
            public event PropertyChangedEventHandler PropertyChanged;
    
            private void OnPropertyChanged(string name)
            {
                    PropertyChangedEventHandler handler = PropertyChanged;
                    if (handler != null)
                    {
                        handler(this, new PropertyChangedEventArgs(name));
                    }
             }
    
            public void BingoText_TextChanged(object sender, TextChangedEventArgs e)
             {
                 Text = this.BingoText.Text;
             }
    
            public delegate void CheckedStateChangedEventHandler(object sender, CheckedEventArgs e);
            public event CheckedStateChangedEventHandler CheckedChanged;
            private int p;
    
     
            public void BingoBtn_Click(object sender, RoutedEventArgs e)
            {
                Checked = !Checked;
                if(Checked)
                {
                    Chip.Visibility = Visibility.Visible;
                }
                else
                {
                    Chip.Visibility = Visibility.Collapsed;
                }
                if (CheckedChanged != null)
                {
                    CheckedEventArgs ev = new CheckedEventArgs();
                    ev.Checked = Checked;
                    ev.Text = Text;
                    CheckedChanged(this, ev);
                }
            }
        }
    
        public class CheckedEventArgs : EventArgs
        {
            public bool Checked {get; set;}
            public string Text { get; set; }
        }
    




    Larry Maturo

    Thursday, November 20, 2014 2:25 PM
  • Well, I fixed the problem.  I created a new project and added the two controls to the new project and it worked.  Go figure.

    Larry Maturo

    • Marked as answer by lmaturo Saturday, November 22, 2014 7:14 PM
    Saturday, November 22, 2014 7:14 PM
  • Nice to see that, the screenshot I pasted here is splash screen, not a control.

    Generally create a new project can fix most of the display issue.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Monday, November 24, 2014 1:24 AM
    Moderator
  • Hi James,

    Thank you.  I'll remember that.  I've never seen that before, so I tried it out of desperation.  I was very surprised that it actually worked.

    -- Larry


    Larry Maturo

    Monday, November 24, 2014 2:17 PM