下面是弹窗效果图

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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.Shapes;
using WPF.DazzleUI2.Controls;
namespace DialogEx.MessageBoxEx
{
/// <summary>
/// 无边框消息对话框
/// </summary>
public partial class MessageBoxExWindow : DazzleWindow
{
public MessageBoxExResult Result { get; set; }
public MessageBoxExWindow()
{
InitializeComponent();
}
//关闭
private void ButtonClose_Click(object sender, RoutedEventArgs e)
{
Result = MessageBoxExResult.Cancel;
this.Close();
}
//按钮事件
private void ItemsControl_MouseUp(object sender, MouseButtonEventArgs e)
{
if (e.OriginalSource.GetType() == typeof(Button))
{
FrameworkElement btn = (FrameworkElement)e.OriginalSource;
if (btn.Tag != null && btn.Tag.GetType() == typeof(MessageBoxExResult))
{
this.Result = (MessageBoxExResult)btn.Tag;
this.Close();
}
}
}
private void DazzleWindow_Loaded(object sender, RoutedEventArgs e)
{
}
}
}
```xml
<dui:DazzleWindow x:Class="DialogEx.MessageBoxEx.MessageBoxExWindow"
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:dui="clr-namespace:WPF.DazzleUI2.Controls;assembly=WPF.DazzleUI2"
mc:Ignorable="d"
xmlns:cvt="clr-namespace:DialogEx.Converters"
Title="DialogEx"
ShowInTaskbar="False"
WindowStartupLocation="CenterScreen"
Width="330"
Height="165"
Loaded="DazzleWindow_Loaded"
ResizeMode="NoResize"
>
<Window.Resources>
<ResourceDictionary>
<cvt:HiddenConverter x:Key="HiddenCvt"/>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/DialogEx;Component/Resource/App.xaml"/>
<ResourceDictionary Source="pack://application:,,,/DialogEx;Component/Resource/Style/QQ2015.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="33"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="33"></RowDefinition>
</Grid.RowDefinitions>
<Grid Grid.Row="0" Background="{DynamicResource TipColor}">
<Label Content="{Binding Title}" Foreground="{DynamicResource TipFontColor}" Height="25" HorizontalAlignment="Left" MinWidth="50" VerticalContentAlignment="Center" Margin="10,0,0,0"></Label>
<Button Height="30" Width="30" Style="{DynamicResource BtnClose}" HorizontalAlignment="Right" Margin="0,-2,5,0" Click="ButtonClose_Click" ></Button>
</Grid>
<StackPanel Grid.Row="1" Margin="10,0,10,0" Background="{DynamicResource ContentColor}" Orientation="Horizontal">
<Image Name="ImageContent" Width="50" Height="50" VerticalAlignment="Top" Margin="0,10,0,0" Visibility="{Binding ImageVisible,Converter={StaticResource HiddenCvt}}" Source="{Binding ImageSource}">
</Image>
<TextBlock TextWrapping="Wrap" MaxWidth="250" Margin="5,15,0,0" Text="{Binding Content}" >
<TextBlock.Style>
<Style TargetType="TextBlock">
<Setter Property="FontSize" Value="18" ></Setter>
</Style>
</TextBlock.Style>
</TextBlock>
</StackPanel>
<Grid Grid.Row="2" Background="{DynamicResource BtnAreaColor}">
<ItemsControl ItemsSource="{Binding BtnList}" Style="{DynamicResource ItemsListStyle}" PreviewMouseUp="ItemsControl_MouseUp">
</ItemsControl>
</Grid>
</Grid>
</dui:DazzleWindow>
需直接要dome的联系 q q :1442601713

本文介绍如何在WPF中创建并自定义弹窗框的样式,通过实例展示了一个弹窗的最终效果,并提供了联系方式以获取具体代码示例。

被折叠的 条评论
为什么被折叠?



