WPF 自定义MessageBox 弹窗提示 弹窗加载
1. 下载Dll
https://pan.baidu.com/s/1sKGQ0uHXHkkhXtMvUYPQHA
2.在项目中添加引用
略
3.在Xaml中引入名称空间
xmlns:myControl ="clr-namespace:MyCustomControlLibrary;assembly=MyCustomControlLibrary"
5.使用代码
Xaml
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
<TextBlock Text="提示效果" Foreground="Black" FontSize="16" FontWeight="DemiBold" HorizontalAlignment="Center"/>
<WrapPanel>
<myControl:IconButton Content="提示1" x:Name="AlertOne" Margin="5" Padding="2" IsShowIcon="False" Width="50" HorizontalAlignment="Center" Click="AlertOne_Click"/>
<myControl:IconButton Content="提示2" x:Name="AlertTwo" Margin="5" Padding="2" IsShowIcon="False" Width="50" HorizontalAlignment="Center" Click="AlertTwo_Click"/>
<myControl:IconButton Content="提示3" x:Name="AlertThree" Margin="5" Padding="2" IsShowIcon="False" Width="50" HorizontalAlignment="Center" Click="AlertThree_Click"/>
</WrapPanel>
<TextBlock Text="加载效果" Foreground="Black" FontSize="16" FontWeight="DemiBold" HorizontalAlignment="Center"/>
<WrapPanel>
<myControl:IconButton Content="加载1" x:Name="loadOne" Margin="5" Padding="2" IsShowIcon="False" Width="50" HorizontalAlignment="Center" Click="loadOne_Click"/>
<myControl:IconButton Content="加载2" x:Name="loadTwo" Margin="5" Padding="2" IsShowIcon="False" Width="50" HorizontalAlignment="Center" Click="loadTwo_Click"/>
<myControl:IconButton Content="加载3" x:Name="loadThree" Margin="5" Padding="2" IsShowIcon="False" Width="50" HorizontalAlignment="Center" Click="loadThree_Click"/>
</WrapPanel>
<WrapPanel>
<myControl:IconButton Content="加载4" x:Name="loadFour" Margin="5" Padding="2" IsShowIcon="False" Width="50" HorizontalAlignment="Center" Click="loadFour_Click"/>
<myControl:IconButton Content="加载5" x:Name="loadfive" Margin="5" Padding="2" IsShowIcon="False" Width="50" HorizontalAlignment="Center" Click="loadfive_Click"/>
<myControl:IconButton Content="加载6" x:Name="loadSix" Margin="5" Padding="2" IsShowIcon="False" Width="50" HorizontalAlignment="Center" Click="loadSix_Click"/>
</WrapPanel>
<WrapPanel>
<myControl:IconButton Content="加载7" x:Name="loadSever" Margin="5" Padding="2" IsShowIcon="False" Width="50" HorizontalAlignment="Center" Click="loadSever_Click"/>
<myControl:IconButton Content="加载8" x:Name="loadeight" Margin="5" Padding="2" IsShowIcon="False" Width="50" HorizontalAlignment="Center" Click="loadeight_Click"/>
<myControl:IconButton Content="加载9" x:Name="loadnine" Margin="5" Padding="2" IsShowIcon="False" Width="50" HorizontalAlignment="Center" Click="loadnine_Click"/>
</WrapPanel>
<WrapPanel>
<TextBlock Foreground="#787978" FontSize="14" Text="加载动画很多,可以自由组织 。" Padding="10,15,0,0" MouseLeftButtonUp="OnePointLoading_MouseLeftButtonUp"/>
</WrapPanel>
<TextBlock Text="自定义MessageBox效果" Foreground="Black" FontSize="16" FontWeight="DemiBold" HorizontalAlignment="Center" Margin="0,10,0,0"/>
<WrapPanel>
<myControl:IconButton Content="效果1" x:Name="MessageboxOne" Margin="5" Padding="2" IsShowIcon="False" Width="50" HorizontalAlignment="Center" Click="MessageboxOne_Click"/>
<myControl:IconButton Content="效果2" x:Name="MessageboxTwo" Margin="5" Padding="2" IsShowIcon="False" Width="50" HorizontalAlignment="Center" Click="MessageboxTwo_Click"/>
<myControl:IconButton Content="效果3" x:Name="MessageboxThree" Margin="5" Padding="2" IsShowIcon="False" Width="50" HorizontalAlignment="Center" Click="MessageboxThree_Click"/>
</WrapPanel>
<!--<StackPanel>
--><!--<TextBlock Foreground="#787978" FontSize="14" Text="正在检测新版本..." Padding="10,15,0,0" MouseLeftButtonUp="OnePointLoading_MouseLeftButtonUp"/>--><!--
</StackPanel>-->
</StackPanel>
Cs代码中
private void AlertOne_Click(object sender, RoutedEventArgs e)
{
MyCustomControlLibrary.MMessageBox.ShowAlert(
"Success!",
Orientation.Horizontal,
null,
"#3ca9fe",
false);
// MyCustomControlLibrary.MMessageBox.ShowSuccessAlert();
// MyCustomControlLibrary.MMessageBox.ShowSuccessAlert("Success!");
}
private void AlertTwo_Click(object sender, RoutedEventArgs e)
{
var point = this.Mborder.PointToScreen(new Point());
//Mborder 窗口内容区域的边框
var size = new Size(this.Mborder.ActualWidth, this.Mborder.ActualHeight);
MyCustomControlLibrary.MMessageBox.ShowModalAlert(
"Success!",
point,
size,
Orientation.Vertical,
String.Empty,
"#3ca9fe");
//MyCustomControlLibrary.MMessageBox.ShowSuccessModelAlert(size,point);
//MyCustomControlLibrary.MMessageBox.ShowSuccessModelAlert(size, point, "Success!");
}
private void AlertThree_Click(object sender, RoutedEventArgs e)
{
var point = this.Mborder.PointToScreen(new Point());
//Mborder 窗口内容区域的边框
var size = new Size(this.Mborder.ActualWidth, this.Mborder.ActualHeight);
MyCustomControlLibrary.MMessageBox.ShowModalAlert(
"Success!",
point,
size,
Orientation.Vertical,
null,
"#ffffffff");
}
private void loadOne_Click(object sender, RoutedEventArgs e)
{
MyCustomControlLibrary.MMessageBox.ShowLoading(
MyCustomControlLibrary.MMessageBox.LoadType.Circle,
"加载中。。。",
new Point(0, 0),
new Size(0, 0),
"",
Orientation.Horizontal,
"#ffffff",
3);
}
private void loadTwo_Click(object sender, RoutedEventArgs e)
{
var point = this.Mborder.PointToScreen(new Point());
//Mborder 窗口内容区域的边框
var size = new Size(this.Mborder.ActualWidth, this.Mborder.ActualHeight);
MyCustomControlLibrary.MMessageBox.ShowLoading(
MyCustomControlLibrary.MMessageBox.LoadType.Circle,
String.Empty,
point,
size,
"",
Orientation.Horizontal,
"#ffffff",
3);
}
private void loadThree_Click(object sender, RoutedEventArgs e)
{
var point = this.Mborder.PointToScreen(new Point());
//Mborder 窗口内容区域的边框
var size = new Size(this.Mborder.ActualWidth, this.Mborder.ActualHeight);
MyCustomControlLibrary.MMessageBox.ShowLoading(
MyCustomControlLibrary.MMessageBox.LoadType.Three,
"Loading...",
new Point(0, 0),
new Size(0, 0),
null,
Orientation.Vertical,
"#ffffff",
3);
}
private void loadFour_Click(object sender, RoutedEventArgs e)
{
var point = this.Mborder.PointToScreen(new Point());
//Mborder 窗口内容区域的边框
var size = new Size(this.Mborder.ActualWidth, this.Mborder.ActualHeight);
MyCustomControlLibrary.MMessageBox.ShowLoading(
MyCustomControlLibrary.MMessageBox.LoadType.Foure,
"Loading...",
point,
size,
"",
Orientation.Vertical,
"#ffffff",
5);
}
private void loadfive_Click(object sender, RoutedEventArgs e)
{
var point = this.Mborder.PointToScreen(new Point());
//Mborder 窗口内容区域的边框
var size = new Size(this.Mborder.ActualWidth, this.Mborder.ActualHeight);
MyCustomControlLibrary.MMessageBox.ShowLoading(
MyCustomControlLibrary.MMessageBox.LoadType.Two,
"Loading...",
point,
size,
"",
Orientation.Vertical,
"#ffffff",
3);
}
private void loadSix_Click(object sender, RoutedEventArgs e)
{
var point = this.Mborder.PointToScreen(new Point());
//Mborder 窗口内容区域的边框
var size = new Size(this.Mborder.ActualWidth, this.Mborder.ActualHeight);
MyCustomControlLibrary.MMessageBox.ShowLoading(
MyCustomControlLibrary.MMessageBox.LoadType.Firve,
"Loading...",
point,
size,
"",
Orientation.Vertical,
"#ffffff",
3);
}
private void loadSever_Click(object sender, RoutedEventArgs e)
{
MyCustomControlLibrary.MMessageBox.ShowLoading(
MyCustomControlLibrary.MMessageBox.LoadType.One,
"Loading...",
new Point(0, 0),
new Size(0, 0),
null,
Orientation.Vertical,
"#ffffff",
3);
}
private void loadeight_Click(object sender, RoutedEventArgs e)
{
var point = this.Mborder.PointToScreen(new Point());
//Mborder 窗口内容区域的边框
var size = new Size(this.Mborder.ActualWidth, this.Mborder.ActualHeight);
MyCustomControlLibrary.MMessageBox.ShowLoading(
MyCustomControlLibrary.MMessageBox.LoadType.Grid,
"Loading...",
point,
size,
"",
Orientation.Vertical,
"#ffffff",
3);
}
private void loadnine_Click(object sender, RoutedEventArgs e)
{
var point = this.Mborder.PointToScreen(new Point());
//Mborder 窗口内容区域的边框
var size = new Size(this.Mborder.ActualWidth, this.Mborder.ActualHeight);
MyCustomControlLibrary.MMessageBox.ShowLoading(
MyCustomControlLibrary.MMessageBox.LoadType.One,
"Loading...",
point,
size,
"",
Orientation.Vertical,
"#ffffff",
3);
}
private void MessageboxOne_Click(object sender, RoutedEventArgs e)
{
MyCustomControlLibrary.MMessageBox.Reault reault = MyCustomControlLibrary.MMessageBox.ShouBox(
"操作成功!",
"信息",
MyCustomControlLibrary.MMessageBox.ButtonType.No,
MyCustomControlLibrary.MMessageBox.IconType.success
);
if (reault == MyCustomControlLibrary.MMessageBox.Reault.No)
{
MyCustomControlLibrary.MMessageBox.ShowSuccessAlert("你点了 取消");
}
}
private void MessageboxTwo_Click(object sender, RoutedEventArgs e)
{
MyCustomControlLibrary.MMessageBox.Reault reault = MyCustomControlLibrary.MMessageBox.ShouBox(
"操作成功!",
"信息",
MyCustomControlLibrary.MMessageBox.ButtonType.Yes,
MyCustomControlLibrary.MMessageBox.IconType.success
);
var point = this.Mborder.PointToScreen(new Point());
//Mborder 窗口内容区域的边框
var size = new Size(this.Mborder.ActualWidth, this.Mborder.ActualHeight);
if (reault == MyCustomControlLibrary.MMessageBox.Reault.Yes)
{
MyCustomControlLibrary.MMessageBox.ShowSuccessModelAlert(size, point, "你点了 确定");
}
}
private void MessageboxThree_Click(object sender, RoutedEventArgs e)
{
MyCustomControlLibrary.MMessageBox.Reault reault = MyCustomControlLibrary.MMessageBox.ShouBox(
"是否要删除!",
"警 告",
MyCustomControlLibrary.MMessageBox.ButtonType.YesNo,
MyCustomControlLibrary.MMessageBox.IconType.warring,
Orientation.Horizontal,
"是",
"否"
);
if (reault == MyCustomControlLibrary.MMessageBox.Reault.Yes)
{
MyCustomControlLibrary.MMessageBox.ShowSuccessAlert("你点了 是");
}
else
{
MyCustomControlLibrary.MMessageBox.ShowSuccessAlert("你点了 否");
}
}
————————————————
版权声明:本文为CSDN博主「badxnui」的原创文章,遵循CC 4.0 by-sa版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/badxnui/article/details/80338423