静态资源样式引用到自定义控件
This commit is contained in:
1 parent
167885814e
commit
3fe394c8da
18 files changed
+191
-51
No files matched your search
@@ -5,14 +5,31 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:_29WxOrderWpf.BaseWindows"
|
||||
mc:Ignorable="d" Style="{StaticResource BaseNoneBorderWindowStyle}"
|
||||
Title="BaseMsgWindow" Height="450" Width="800">
|
||||
Title="BaseMsgWindow" Height="250" Width="350">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="32"></RowDefinition>
|
||||
<RowDefinition Height="*"></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
<userctrols:WindowBoxes VerticalAlignment="Center" HorizontalAlignment="Right" Margin="4" MinBoxVisibility="Collapsed" MaxBoxVisibility="Collapsed"/>
|
||||
<Label x:Name="lblTitle" Margin="2,2" Foreground="White" Content="title"></Label>
|
||||
<userctrols:UcWindowBoxes VerticalAlignment="Center" HorizontalAlignment="Right" Margin="4" MinBoxVisibility="Collapsed" MaxBoxVisibility="Collapsed"/>
|
||||
<Border Margin="2,0,2,2" Grid.Row="1" Background="White">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="120"></ColumnDefinition>
|
||||
<ColumnDefinition Width="*"></ColumnDefinition>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Image x:Name="imgTip" Source="{StaticResource imgBaseMsgInfo}" Stretch="Uniform" Width="64" Height="64" VerticalAlignment="Top" Margin="0,30" />
|
||||
<Grid Grid.Column="1">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"></RowDefinition>
|
||||
<RowDefinition Height="80"></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
<Label x:Name="lblMsg" Content="message" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0,30,30,30"/>
|
||||
<Button x:Name="btnCancel" Content="取消" HorizontalAlignment="Right" Margin="0,20,30,0" Grid.Row="1" VerticalAlignment="Top" Width="75" Height="26" Click="btnCancel_Click"/>
|
||||
<Button x:Name="btnOk" Content="确定" HorizontalAlignment="Right" Margin="0,20,130,0" Grid.Row="1" VerticalAlignment="Top" Width="75" Height="26" Click="btnOk_Click"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
</local:BaseWindow>
|
||||
@@ -24,5 +24,55 @@ namespace _29WxOrderWpf.BaseWindows
|
||||
InitializeComponent();
|
||||
this.DataContext = this;
|
||||
}
|
||||
|
||||
private static BaseMsgWindow CreateMsgForm(string msg, string caption, MsgWindowLevel fl)
|
||||
{
|
||||
BaseMsgWindow msgBox = new BaseMsgWindow { lblTitle = { Content = caption }, lblMsg = { Content = msg } };
|
||||
if (fl.Equals(MsgWindowLevel.LARGE))
|
||||
{
|
||||
msgBox.Width = (int)MsgWindowLevel.LARGE;
|
||||
msgBox.Height = 500;
|
||||
}
|
||||
msgBox.btnOk.Margin = new Thickness(msgBox.btnCancel.Margin.Left, msgBox.btnCancel.Margin.Top, msgBox.btnCancel.Margin.Right, msgBox.btnCancel.Margin.Bottom); // 把确认按钮移到取消按钮上面
|
||||
msgBox.btnCancel.Visibility = Visibility.Collapsed;
|
||||
return msgBox;
|
||||
}
|
||||
|
||||
public static BaseMsgWindow ShowConfirm(Window window, string msg, string caption = "", MsgWindowLevel fl = MsgWindowLevel.MEDIUM)
|
||||
{
|
||||
string title = string.IsNullOrEmpty(caption) ? "确认系统提示" : caption;
|
||||
BaseMsgWindow msgBox = new BaseMsgWindow
|
||||
{
|
||||
lblTitle = { Content = title },
|
||||
lblMsg = { Content = msg },
|
||||
imgTip = { Source = Application.Current.Resources["imgBaseMsgQue"] as ImageSource },
|
||||
};
|
||||
if (fl.Equals(MsgWindowLevel.LARGE))
|
||||
{
|
||||
msgBox.Width = (int)MsgWindowLevel.LARGE;
|
||||
msgBox.Height = 500;
|
||||
}
|
||||
if (window != null)
|
||||
msgBox.Owner = window;
|
||||
msgBox.ShowDialog();
|
||||
return msgBox;
|
||||
}
|
||||
|
||||
private void btnOk_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
DialogResult = true;
|
||||
}
|
||||
|
||||
private void btnCancel_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
DialogResult = false;
|
||||
}
|
||||
}
|
||||
|
||||
public enum MsgWindowLevel
|
||||
{
|
||||
SMALL,
|
||||
MEDIUM,
|
||||
LARGE = 500
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user