C# 页面中的wpf对话框
当我在网页上工作时,我经常使用这些。前几天,在为WPF项目构建一个页面时,我最终构建了一个页面,它看起来像是有一个页面内对话框,但它是页面上唯一的东西 我的问题是。是否有人创建了这样的组件,允许轻松创建此类对话框C# 页面中的wpf对话框,c#,.net,wpf,xaml,C#,.net,Wpf,Xaml,当我在网页上工作时,我经常使用这些。前几天,在为WPF项目构建一个页面时,我最终构建了一个页面,它看起来像是有一个页面内对话框,但它是页面上唯一的东西 我的问题是。是否有人创建了这样的组件,允许轻松创建此类对话框 使用系统; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls
使用系统;
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;
using System.ComponentModel;
namespace xxx.Wpf
{
/// <summary>
/// Interaction logic for InPageDialog.xaml
/// </summary>
public partial class InPageDialog : UserControl, INotifyPropertyChanged
{
public InPageDialog()
{
InitializeComponent();
}
public void Show(IDialog ucContent)
{
}
void ucContent_OnClose(object obj)
{
}
protected virtual void Changed(string propertyName)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(propertyName));
}
}
public static readonly DependencyProperty ContentBackgroundProperty = DependencyProperty.Register("ContentBackground", typeof(Brush), typeof(InPageDialog), new UIPropertyMetadata(Brushes.White));
public Brush ContentBackground
{
get { return (Brush)GetValue(ContentBackgroundProperty); }
set { SetValue(ContentBackgroundProperty, value); }
}
public static readonly DependencyProperty ContentBorderBrushProperty = DependencyProperty.Register("ContentBorderBrush", typeof(Brush), typeof(InPageDialog), new UIPropertyMetadata(Brushes.White));
public Brush ContentBorderBrush
{
get { return (Brush)GetValue(ContentBorderBrushProperty); }
set { SetValue(ContentBorderBrushProperty, value); }
}
public static readonly DependencyProperty ContentActiveBackgroundProperty = DependencyProperty.Register("ContentActiveBackground", typeof(Brush), typeof(InPageDialog), new UIPropertyMetadata(Brushes.White));
public Brush ContentActiveBackground
{
get { return (Brush)GetValue(ContentActiveBackgroundProperty); }
set { SetValue(ContentActiveBackgroundProperty, value); }
}
public static readonly DependencyProperty ContentBorderThicknessProperty = DependencyProperty.Register("ContentBorderThickness", typeof(Thickness), typeof(InPageDialog));
public Thickness ContentBorderThickness
{
get { return (Thickness)GetValue(ContentBorderThicknessProperty); }
set { SetValue(ContentBorderThicknessProperty, value); }
}
public static readonly DependencyProperty ContentBlurRadiusProperty = DependencyProperty.Register("ContentBlurRadius", typeof(double), typeof(InPageDialog));
public double ContentBlurRadius
{
get { return (double)GetValue(ContentBlurRadiusProperty); }
set { SetValue(ContentBlurRadiusProperty, value); }
}
public event PropertyChangedEventHandler PropertyChanged;
}
public interface IDialog
{
event Action<object> OnClose;
}
}
<UserControl x:Class="xxx.Wpf.InPageDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:me="clr-namespace:xxx.Wpf"
Visibility="Collapsed" DataContext="{Binding}">
<UserControl.Resources>
<Style TargetType="{x:Type Button}">
<Setter Property="Margin" Value="4"/>
<Setter Property="Width" Value="60"/>
</Style>
</UserControl.Resources>
<UserControl.Template>
<ControlTemplate TargetType="{x:Type me:InPageDialog}">
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" DataContext="{TemplateBinding DataContext}">
<Rectangle HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Opacity="0.765"
Fill="{TemplateBinding ContentBackground}" />
<Border VerticalAlignment="Center"
HorizontalAlignment="Center"
CornerRadius="5"
BorderBrush="{TemplateBinding ContentBorderBrush}"
BorderThickness="{TemplateBinding ContentBorderThickness}"
Background="{TemplateBinding ContentActiveBackground}" >
<ContentPresenter Margin="0" Width="Auto" Height="Auto" Content="{TemplateBinding Content}" />
</Border>
</Grid>
</ControlTemplate>
</UserControl.Template>
</UserControl>
使用System.Collections.Generic;
使用System.Linq;
使用系统文本;
使用System.Windows;
使用System.Windows.Controls;
使用System.Windows.Data;
使用System.Windows.Documents;
使用System.Windows.Input;
使用System.Windows.Media;
使用System.Windows.Media.Imaging;
使用System.Windows.Navigation;
使用System.Windows.Shapes;
使用系统组件模型;
名称空间xxx.Wpf
{
///
///InPageDialog.xaml的交互逻辑
///
InPageDialog中的公共分部类:UserControl,INotifyPropertyChanged
{
公共InPageDialog()
{
初始化组件();
}
公开作废显示(IDialog ucContent)
{
}
无效内容关闭(对象对象对象)
{
}
受保护的虚拟无效已更改(字符串propertyName)
{
PropertyChangedEventHandler处理程序=PropertyChanged;
if(处理程序!=null)
{
处理程序(这是新的PropertyChangedEventArgs(propertyName));
}
}
公共静态只读DependencyProperty ContentBackgroundProperty=DependencyProperty.Register(“ContentBackground”、typeof(Brush)、typeof(InPageDialog)、new UIPropertyMetadata(Brush.White));
公共内容背景
{
获取{return(Brush)GetValue(ContentBackgroundProperty);}
set{SetValue(ContentBackgroundProperty,value);}
}
公共静态只读DependencyProperty ContentBorderBrushProperty=DependencyProperty.Register(“ContentBorderBrush”、typeof(Brush)、typeof(InPageDialog)、new UIPropertyMetadata(Brush.White));
公共刷子
{
获取{return(画笔)GetValue(ContentBorderBrushProperty);}
set{SetValue(ContentBorderBrushProperty,value);}
}
公共静态只读DependencyProperty ContentActiveBackgroundProperty=DependencyProperty.Register(“ContentActiveBackground”、typeof(Brush)、typeof(InPageDialog)、new-UIPropertyMetadata(Brush.White));
公共笔刷内容活动背景
{
获取{return(Brush)GetValue(ContentActiveBackgroundProperty);}
set{SetValue(ContentActiveBackgroundProperty,value);}
}
公共静态只读DependencyProperty ContentBorderThicknessProperty=DependencyProperty.Register(“ContentBorderThickness”、typeof(Thickness)、typeof(InPageDialog));
公共厚度
{
获取{return(Thickness)GetValue(ContentBorderThicknessProperty);}
set{SetValue(ContentBorderThicknessProperty,value);}
}
public static readonly dependencProperty ContentBlurRadiusProperty=dependencProperty.Register(“ContentBlurRadius”、typeof(double)、typeof(InPageDialog));
公共双内容半径
{
获取{return(double)GetValue(ContentBlurRadiusProperty);}
设置{SetValue(ContentBlurRadiusProperty,value);}
}
公共事件属性更改事件处理程序属性更改;
}
公共接口IDialog
{
事件-行动-失败;
}
}
是项目的开始,为我们在我的工作中所做的工作而努力。我现在也在一些地方发展了自己的工作,似乎应该有一些资源以更一致的方式来做这件事。如果我发现什么,我会回来报到。