如何在标题栏中添加图像?

编程入门 行业动态 更新时间:2024-10-09 20:22:01
本文介绍了如何在标题栏中添加图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

标题栏中的图标太小,因此我想添加Image而不是Icon。

The icon in the title bar is too small, so I want to add Image instead of Icon.

推荐答案

如果我不喜欢使用该图标,唯一的方法是创建一个自定义标题栏,...

If you don't like to use the icon, the single way to do this is to make a custom title bar, I think...

您可以使用以下代码:这是XAML代码:

You can use this code: This is the XAML code:

<Window x:Class="WpfApplication1.MainWindow" xmlns="schemas.microsoft/winfx/2006/xaml/presentation" xmlns:x="schemas.microsoft/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525" WindowStyle="None"> <Grid> <Border BorderBrush="#FF00860C" BorderThickness="3" Name="border1" Margin="0,30,0,0"></Border> <Rectangle Name="rectangle1" Stroke="#FF2446FF" StrokeThickness="3" Height="30" VerticalAlignment="Top" MouseDown="rectangle1_MouseDown"> <Rectangle.Fill> <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> <GradientStop Color="White" Offset="0.013" /> <GradientStop Color="White" Offset="1" /> <GradientStop Color="#FF7CAEFF" Offset="0.477" /> </LinearGradientBrush> </Rectangle.Fill> </Rectangle> <Button Content="X" Height="24" HorizontalAlignment="Right" Margin="0,3,3,0" Name="button1" VerticalAlignment="Top" Width="23" Click="button1_Click" /> <Button Content="□" Height="24" HorizontalAlignment="Right" Margin="0,3,26,0" Name="button2" VerticalAlignment="Top" Width="23" Click="button2_Click" /> <Button Content="__" Height="24" HorizontalAlignment="Right" Margin="0,3,49,0" Name="button3" VerticalAlignment="Top" Width="23" Click="button3_Click" /> <TextBlock Height="23" HorizontalAlignment="Left" Margin="102,4,0,0" Name="textBlock1" Text="Custom Title bar" VerticalAlignment="Top" FontSize="18" MouseDown="rectangle1_MouseDown"/> <Image Height="22" HorizontalAlignment="Left" Margin="8,4,0,0" Name="image1" Stretch="Fill" VerticalAlignment="Top" Width="26" /> </Grid>

这是C#代码:

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; namespace WpfApplication1 { /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } private void button1_Click(object sender, RoutedEventArgs e) { this.Close(); } private void button2_Click(object sender, RoutedEventArgs e) { if (this.WindowState == WindowState.Maximized) this.WindowState = WindowState.Normal; else this.WindowState = WindowState.Maximized; } private void button3_Click(object sender, RoutedEventArgs e) { this.WindowState = WindowState.Minimized; } private void rectangle1_MouseDown(object sender, MouseButtonEventArgs e) { DragMove(); } } }

更多推荐

如何在标题栏中添加图像?

本文发布于:2023-11-28 19:05:30,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1643597.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:栏中   图像   标题   如何在

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!