我在应用程序WPF中有一个UserControl,但是当一切正常时,我不会使用它来显示文本块“ tBlockLunarDay”。我试图修复,但我做不到。你能帮我解决这个问题吗?
我的userControls
<UserControl x:Class="CalendarPlus.ControlCalendar"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:CalendarPlus"
mc:Ignorable="d"
d:DesignHeight="60" d:DesignWidth="60" Loaded="ControlCalendar_OnLoaded">
<Grid>
<Border x:Name="border" BorderThickness="1" BorderBrush="Red" CornerRadius="7">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1.5*"></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="1.5*"></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Canvas>
<TextBlock x:Name="tBlockDay" FontFamily="Times New Roman" FontWeight="Bold" TextAlignment="Center" FontSize="30" Width="30" Height="30" Padding="0" Canvas.Left="5" Canvas.Top="3" Foreground="AliceBlue">5</TextBlock>
</Canvas>
<Canvas Grid.Row="1" Grid.Column="1" ZIndex="99" Visibility="Visible" IsEnabled="True">
<TextBlock x:Name="tBlockLunarDay" Foreground="AntiqueWhite" FontFamily="Times New Roman" FontSize="12" TextAlignment="Center" FontWeight="Bold" FontStyle="Italic" Width="20" Height="20" Canvas.Top="2" Canvas.Left="1" Visibility="Visible" IsEnabled="True">19</TextBlock>
</Canvas>
<Canvas Grid.Column="1">
<Image x:Name="imgStar" Width="15" Height="15" Canvas.Top="3" Canvas.Right="3" Source="pack://siteoforigin:,,,/Resources/Star512.png"></Image>
</Canvas>
</Grid>
</Border>
</Grid>
</UserControl>
我无法上载大部分代码,因此对于由此带来的不便,请谅解。这是.CS文件中的代码 https://drive.google.com/open?id=1GI-3BIYsqh5IFFTIMY3ubFFxscQT4Ei6
答案 0 :(得分:1)
我刚刚尝试过,您只需要更改文本的颜色,我也看不到“ AntiqueWhite”文本。
也不确定是否是故意的,但是如果您使用画布来布局文本框,则可以像下面那样在textbox标签内设置它们的位置。
<TextBlock Grid.Row="1" Grid.Column="1" x:Name="tBlockLunarDay" Foreground="Black" FontFamily="Times New Roman" FontSize="12" TextAlignment="Center" FontWeight="Bold" FontStyle="Italic" Width="20" Height="20" Canvas.Top="2" Canvas.Left="1" Visibility="Visible" IsEnabled="True">19</TextBlock>