IUFITS
asked on
Wpf User Control not Displaying
I have created a simple, bare bones wpf project. I added a user control to the project that has a black background and a white label (XAML below). I have the partial class code behind inherit from UserControl so I can add it to my main Window. In my main window, I'm able to add this to the Window tag to be able to use the control in my XAML (and below that is the xaml I use to put it on the Window):
xmlns:Iuf="clr-namespace:W pfTesting. Iuf.Wpf.Co ntrols"
<Grid>
<Iuf:LaunchButton x:Name="LaunchButton1" Width="46" Height="46"></Iuf:LaunchBu tton>
</Grid>
Now... it compiles without error.. however, I can't see the button. If I set properties on it, it will change it like it's a blank control... but never show me what I have included in the XAML below. I'm probably missing something simple, since this isn't a rocket science type application. What is it that I am missing? :)
xmlns:Iuf="clr-namespace:W
<Grid>
<Iuf:LaunchButton x:Name="LaunchButton1" Width="46" Height="46"></Iuf:LaunchBu
</Grid>
Now... it compiles without error.. however, I can't see the button. If I set properties on it, it will change it like it's a blank control... but never show me what I have included in the XAML below. I'm probably missing something simple, since this isn't a rocket science type application. What is it that I am missing? :)
<UserControl x:Class="LaunchButton" Name="LaunchButton"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Width="46" Height="46" MinWidth="46" MinHeight="46" MaxHeight="46" MaxWidth="46">
<Grid Width="46" Height="46" Background="Black">
<Label Foreground="White">Hello</Label>
</Grid>
</UserControl>
ASKER
I changed it to this at your suggestion, it still doesn't show on Window1.xaml (the code for Window1 is the same as above).
<UserControl x:Class="LaunchButton" Name="LaunchButton1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Width="46" Height="46" MinWidth="46" MinHeight="46" MaxHeight="46" MaxWidth="46">
<Grid Width="46" Height="46" Background="Black">
<Label Foreground="White">Hello</Label>
</Grid>
</UserControl>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That did it, I'm typically a WinForms. This is my first XAML Wpf project and the differences are throwing me for loops currently. :)
Thanks a ton, this has been driving me mad all afternoon. :)
Thanks a ton, this has been driving me mad all afternoon. :)
<UserControl x:Class="LaunchButton" Name="LaunchButton"
Name attribute can't be the same as x:Class attribute.
This should work:
<UserControl x:Class="LaunchButton" Name="LaunchButton1"