I apologize if the answer to this question is simple, but I'm just beginning to learn UWP and really can't figure out a solution on my own.
I have a UserControl
called ClockWidget
included in a Canvas
in my main page. When running the application, the control (containing only a TextBlock
) has the correct size, but the text does not seem to be rendered.
MainPage.xaml
<Page
x:Class="SmartMirror.IOT.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:widgets="using:SmartMirror.IOT.Widgets"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Canvas x:Name="Canvas">
<widgets:ClockWidget Width="500" Height="150" />
</Canvas>
</Page>
ClockWidget.xaml
<UserControl
x:Class="SmartMirror.IOT.Widgets.ClockWidget"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:SmartMirror.IOT.Widgets"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:widgetData="using:SmartMirror.Shared.Model.WidgetData"
mc:Ignorable="d">
<TextBlock Text="Hello World" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" />
</UserControl>
Weirdly enough, in the preview of ClockWidget.xaml
, everything is fine, but once inside of MainPage.xaml
, it "disappears".
I've added some screenshots to help clarify the issue.
As you can see, ClockWidget.xaml
on its own seems to be working fine, the text shows up.
However, once I slot it into MainPage.xaml
, it does not show up. I have the ClockWidget
selected in this screenshot, so as you can see, the size is still correct, but the TextView
disappeared.
So, as it had to, it boiled down to an incredibly stupid mistake. Inside my ClockWidget.xaml.cs
code-behind, I overwrote the default constructor, but accidentally deleted the InitializeComponent()
call. So obviously, the components were never initialized...
Thank you all for your help and support!