我有一个Windows窗体应用程序,它在大多数应用程序窗体上显示应用程序名称,如下所示。对于应用程序名称' VScodePrint 2015'我使用了位图。为了支持高分辨率屏幕,我必须制作此图像的许多副本以支持不同的DPI设置。
我刚刚开始使用WPF重新设计我的应用程序,以避免在不使用图像的情况下根据DPI设置设置不同的图像。
我创建了一个WPF窗口,但不确定如何呈现应用程序名称,如上面的Windows窗体版本。
有些人可以告诉我如何使用XAML按照Windows Form版本呈现应用程序吗?
答案 0 :(得分:0)
System.IO.Path.GetFileName(Assembly.GetEntryAssembly().GetName().Name);
设置一个标签或任何控件的内容等于你,你会得到你想要的名字。
答案 1 :(得分:0)
我已设法创建一个usercontrol,为我的窗口呈现Window标题。我是新手使用WPF,所以这可能不是最好的XAML,但在这里是:
<UserControl x:Class="WindowTitle"
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:WpfApplication2"
mc:Ignorable="d" Height="109.986" Width="404.929">
<RowDefinition Height="80"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Border BorderBrush="DarkGray" BorderThickness="1" CornerRadius="10,10,0,0 " Background="#FF61238B" Margin="0,0,0,1">
<StackPanel Width="Auto" Height="Auto">
<StackPanel Height="Auto" Margin="0,0,0,0" HorizontalAlignment="Center" >
<Label x:Name="lblYear" Content="2015" FontSize="12" BorderBrush="White" Foreground="White" HorizontalContentAlignment="Right" Padding="0,0,0,0" VerticalAlignment="Bottom" FontFamily="Global User Interface" Margin="0,5,0,0"/>
<Label x:Name="lblProductName" Content="VScodePrint" FontSize="48" BorderBrush="White" Foreground="White" HorizontalContentAlignment="Right" Padding="0,0,0,0" VerticalAlignment="Top" FontFamily="Global User Interface" Margin="0,-5,0,0"/>
</StackPanel>
</StackPanel>
</Border>
<Label x:Name="lblVersion" Content="Version 14.0.20 Rev 1510" Grid.Row="1" VerticalAlignment="Center" Height="37" HorizontalContentAlignment="Center" Margin="0,0,0.429,0" FontFamily="Segoe UI Semibold">
<Label.Background>
<SolidColorBrush Color="#FFDBCBE3"/>
</Label.Background>
</Label>
答案 2 :(得分:0)