app.xaml
---------------------------------------------------------------
<Application x:Class="WpfApp.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<!--
<ResourceDictionary Source="Resources/SimpleStyles.xaml" />
-->
<ResourceDictionary Source="Resources/cnblogs_SkyD.xaml" />
<ResourceDictionary Source="Resources/cnblogs_SkyDButton.xaml" />
<ResourceDictionary Source="Resources/TextBox.xaml" />
<ResourceDictionary Source="Resources/Button.xaml" />
<ResourceDictionary Source="Resources/ListBox.xaml" />
<!--
<ResourceDictionary Source="Themes/ListControl.xaml" />
<ResourceDictionary Source="Themes/RadioButtonList.xaml" />
<ResourceDictionary Source="Themes/CheckBoxList.xaml" />
<ResourceDictionary Source="Resources/Shared.xaml" /> -->
<!--<ResourceDictionary Source="Resources/CheckBox.xaml" />
<ResourceDictionary Source="Resources/RadioButton.xaml" />
<ResourceDictionary Source="Resources/ComboBox.xaml" /> -->
<!--<ResourceDictionary Source="Resources/Menu.xaml" />
<ResourceDictionary Source="Resources/ScrollBar.xaml" />
<ResourceDictionary Source="Resources/Expander.xaml" />
<ResourceDictionary Source="Resources/GroupBox.xaml" />-->
<!--<ResourceDictionary Source="Resources/Label.xaml" />-->
<!--<ResourceDictionary Source="Resources/TabControl.xaml" />
<ResourceDictionary Source="Resources/ProgressBar.xaml" />
<ResourceDictionary Source="Resources/Slider.xaml" />
<ResourceDictionary Source="Resources/ToolTip.xaml" />
<ResourceDictionary Source="Resources/TreeView.xaml" />
<ResourceDictionary Source="Resources/ListView.xaml" />
<ResourceDictionary Source="Resources/ScrollViewer.xaml" />
<ResourceDictionary Source="Resources/ToolBar.xaml" />
<ResourceDictionary Source="Resources/StatusBar.xaml" />
<ResourceDictionary Source="Resources/Window.xaml" />
<ResourceDictionary Source="Resources/NavigationWindow.xaml" />-->
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
app.xaml.cs
----------------------------------------
/// <summary>
/// App.xaml 的交互逻辑
/// </summary>
public partial class App : Application
{
public App()
{
this.Startup += new StartupEventHandler(App_Startup);
this.Exit += new ExitEventHandler(App_Exit);
}
private void App_Startup(object sender, StartupEventArgs e)
{
try
{
this.ShutdownMode = System.Windows.ShutdownMode.OnMainWindowClose;
InitializeEngineLicense();
//设置启动界面
Uri u = new Uri("frmMain.xaml", UriKind.Relative);
Application.LoadComponent(u);
//Uri u=new Uri("frmLoginUI.xaml",UriKind.Relative);
this.StartupUri = u; //设置主窗体u
}
catch (Exception ee)
{
MessageBox.Show(ee.Message, "提示");
}
}
void App_Exit(object sender, ExitEventArgs e)
{
ESRI.ArcGIS.ADF.COMSupport.AOUninitialize.Shutdown();
}
private void InitializeEngineLicense()
{
AoInitialize aoi = new AoInitialize();// AoInitializeClass();
//more license choices could be included here
//esriLicenseProductCode productCode = esriLicenseProductCode.esriLicenseProductCodeEngine;
esriLicenseProductCode productCode = esriLicenseProductCode.esriLicenseProductCodeArcServer;
if (aoi.IsProductCodeAvailable(productCode) == esriLicenseStatus.esriLicenseAvailable)
{
aoi.Initialize(productCode);
}
}
}
--------------------------------------------------------
Resoures/TextBox.xaml
--------------------------------------------------------
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!--TextBox样式,这样写可以应用自动所有TextBox OK-->
<Style x:Key="{x:Type TextBox}" TargetType="TextBox">
<Setter Property="KeyboardNavigation.TabNavigation" Value="None"/>
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="AllowDrop" Value="true"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TextBox}">
<Grid>
<Border x:Name="Border" Background="{DynamicResource WindowBackgroundBrush}" BorderBrush="{DynamicResource SolidBorderBrush}" BorderThickness="1" Padding="2" CornerRadius="2">
<!-- The implementation places the Content into the ScrollViewer. It must be named PART_ContentHost for the control to function -->
<ScrollViewer Margin="0" x:Name="PART_ContentHost" Style="{DynamicResource SimpleScrollViewer}" Background="{TemplateBinding Background}"/>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Background" Value="{DynamicResource DisabledBackgroundBrush}" TargetName="Border"/>
<Setter Property="BorderBrush" Value="{DynamicResource DisabledBackgroundBrush}" TargetName="Border"/>
<Setter Property="Foreground" Value="{DynamicResource DisabledForegroundBrush}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!--PasswordBox 样式 OK-->
<Style TargetType="PasswordBox">
<Setter Property="Foreground" Value="Black"/>
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Background" Value="AliceBlue"/>
</Style>
<!--TextBox 标准 手动绑定样式-->
<Style x:Key="NormalTextBoxStyle" TargetType="TextBox">
<Setter Property="ScrollViewer.Background" Value="AliceBlue"/>
<Setter Property="Background" Value="AliceBlue"/>
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Opacity" Value="0" />
</Style>
<!--TextBox 动画 手动绑定样式-->
<Style x:Key="AntoTextStyle" TargetType="{x:Type TextBox}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TextBox}">
<ControlTemplate.Resources>
<Storyboard x:Key="OnMouseEnter1">
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="Bd" Storyboard.TargetProperty="(UIElement.Opacity)">
<SplineDoubleKeyFrame KeyTime="00:00:01" Value="1"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="tbk" Storyboard.TargetProperty="(UIElement.Opacity)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</ControlTemplate.Resources>
<Grid>
<TextBlock x:Name="tbk" Text="{TemplateBinding Text}"/>
<Border SnapsToDevicePixels="true" x:Name="Bd" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Opacity="0">
<ScrollViewer SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" x:Name="PART_ContentHost" Background="AliceBlue"/>
</Border>
</Grid>
<ControlTemplate.Triggers>
<EventTrigger RoutedEvent="Mouse.MouseLeave">
<StopStoryboard BeginStoryboardName="OnMouseEnter1_BeginStoryboard"/>
</EventTrigger>
<EventTrigger RoutedEvent="Mouse.MouseEnter">
<BeginStoryboard x:Name="OnMouseEnter1_BeginStoryboard" Storyboard="{StaticResource OnMouseEnter1}"/>
</EventTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>