文本块不显示
Textblock not showing
我的应用程序 WPF 中有一个 UserControl,但我使用它时文本块 "tBlockLunarDay" 一切正常时不显示。我试图修复但我不能。你能帮我解决一下吗?
我的用户控件
<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
我刚刚试过了,你只需要改变文字的颜色,我也看不到 "AntiqueWhite" 文字。
也不确定这是否是故意的,但如果您使用画布来布置文本框,则可以像下面这样在文本框标记内设置它们的位置。
<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>
我的应用程序 WPF 中有一个 UserControl,但我使用它时文本块 "tBlockLunarDay" 一切正常时不显示。我试图修复但我不能。你能帮我解决一下吗?
我的用户控件
<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
我刚刚试过了,你只需要改变文字的颜色,我也看不到 "AntiqueWhite" 文字。
也不确定这是否是故意的,但如果您使用画布来布置文本框,则可以像下面这样在文本框标记内设置它们的位置。
<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>