Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit eddd016
Showing
17 changed files
with
789 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
*_ReSharper* | ||
*.user | ||
*.suo | ||
*.dbmdl | ||
*.schemaview | ||
*[Bb]in/ | ||
*[Oo]bj/ | ||
*[Dd]ebug/ | ||
*TestResults/ | ||
*[Ll]og.txt | ||
docs/Help | ||
NuGet/lib/ | ||
NuGet/*.nupkg |
69 changes: 69 additions & 0 deletions
69
src/CS.Windows.Controls.WP7/CS.Windows.Controls.WP7.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProductVersion>10.0.20506</ProductVersion> | ||
<SchemaVersion>2.0</SchemaVersion> | ||
<ProjectGuid>{62249A43-7585-4C60-91E3-31BF0AF18C21}</ProjectGuid> | ||
<ProjectTypeGuids>{C089C8C0-30E0-4E22-80C0-CE093F111A43};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>CS.Windows.Controls</RootNamespace> | ||
<AssemblyName>CS.Windows.Controls.WP7</AssemblyName> | ||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> | ||
<SilverlightVersion>$(TargetFrameworkVersion)</SilverlightVersion> | ||
<TargetFrameworkProfile>WindowsPhone71</TargetFrameworkProfile> | ||
<TargetFrameworkIdentifier>Silverlight</TargetFrameworkIdentifier> | ||
<SilverlightApplication>false</SilverlightApplication> | ||
<ValidateXaml>true</ValidateXaml> | ||
<ThrowErrorsInValidation>true</ThrowErrorsInValidation> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>Bin\Debug</OutputPath> | ||
<DefineConstants>DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants> | ||
<NoStdLib>true</NoStdLib> | ||
<NoConfig>true</NoConfig> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>Bin\Release</OutputPath> | ||
<DefineConstants>TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants> | ||
<NoStdLib>true</NoStdLib> | ||
<NoConfig>true</NoConfig> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="System.Windows" /> | ||
<Reference Include="system" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml" /> | ||
<Reference Include="System.Net" /> | ||
<Reference Include="mscorlib.extensions" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
<Resource Include="Themes\Generic.xaml"> | ||
<SubType>Designer</SubType> | ||
<Generator>MSBuild:Compile</Generator> | ||
</Resource> | ||
<Compile Include="WatermarkTextBox.cs" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight for Phone\$(TargetFrameworkVersion)\Microsoft.Silverlight.$(TargetFrameworkProfile).Overrides.targets" /> | ||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight for Phone\$(TargetFrameworkVersion)\Microsoft.Silverlight.CSharp.targets" /> | ||
<ProjectExtensions /> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
using System.Resources; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle( "CS.Windows.Controls.WP7" )] | ||
[assembly: AssemblyDescription( "" )] | ||
[assembly: AssemblyConfiguration( "" )] | ||
[assembly: AssemblyCompany( "Microsoft" )] | ||
[assembly: AssemblyProduct( "CS.Windows.Controls.WP7" )] | ||
[assembly: AssemblyCopyright( "Copyright © Microsoft 2011" )] | ||
[assembly: AssemblyTrademark( "" )] | ||
[assembly: AssemblyCulture( "" )] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible( false )] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid( "2e3aa560-12ae-46fe-8914-ee066cbc4182" )] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Revision and Build Numbers | ||
// by using the '*' as shown below: | ||
[assembly: AssemblyVersion( "1.0.0.0" )] | ||
[assembly: AssemblyFileVersion( "1.0.0.0" )] | ||
[assembly: NeutralResourcesLanguageAttribute( "en-US" )] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
<ResourceDictionary | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows" | ||
xmlns:Controls="clr-namespace:CS.Windows.Controls"> | ||
|
||
<ControlTemplate x:Key="PhoneDisabledTextBoxTemplate" TargetType="Controls:WatermarkTextBox"> | ||
<ContentControl x:Name="ContentElement" BorderThickness="0" Padding="{TemplateBinding Padding}" Margin="{StaticResource PhoneTextBoxInnerMargin}" | ||
HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" /> | ||
</ControlTemplate> | ||
|
||
<Style TargetType="Controls:WatermarkTextBox"> | ||
<Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilyNormal}"/> | ||
<Setter Property="FontSize" Value="{StaticResource PhoneFontSizeMediumLarge}"/> | ||
<Setter Property="Background" Value="{StaticResource PhoneTextBoxBrush}"/> | ||
<Setter Property="Foreground" Value="{StaticResource PhoneTextBoxForegroundBrush}"/> | ||
<Setter Property="BorderBrush" Value="{StaticResource PhoneTextBoxBrush}"/> | ||
<Setter Property="SelectionBackground" Value="{StaticResource PhoneAccentBrush}"/> | ||
<Setter Property="SelectionForeground" Value="{StaticResource PhoneTextBoxSelectionForegroundBrush}"/> | ||
<Setter Property="BorderThickness" Value="{StaticResource PhoneBorderThickness}"/> | ||
<Setter Property="Padding" Value="2"/> | ||
<Setter Property="WatermarkForeground" Value="{StaticResource PhoneTextBoxForegroundBrush}" /> | ||
<Setter Property="WatermarkStyle"> | ||
<Setter.Value> | ||
<Style TargetType="ContentControl"> | ||
<Setter Property="Opacity" Value="0.5" /> | ||
</Style> | ||
</Setter.Value> | ||
</Setter> | ||
<Setter Property="Template"> | ||
<Setter.Value> | ||
<ControlTemplate TargetType="Controls:WatermarkTextBox"> | ||
<Grid Background="Transparent"> | ||
<VisualStateManager.VisualStateGroups> | ||
<VisualStateGroup x:Name="CommonStates"> | ||
<VisualState x:Name="Normal"/> | ||
<VisualState x:Name="MouseOver"/> | ||
<VisualState x:Name="Disabled"> | ||
<Storyboard> | ||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="EnabledBorder" Storyboard.TargetProperty="Visibility"> | ||
<DiscreteObjectKeyFrame KeyTime="0"> | ||
<DiscreteObjectKeyFrame.Value> | ||
<Visibility>Collapsed</Visibility> | ||
</DiscreteObjectKeyFrame.Value> | ||
</DiscreteObjectKeyFrame> | ||
</ObjectAnimationUsingKeyFrames> | ||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="DisabledOrReadonlyBorder" Storyboard.TargetProperty="Visibility"> | ||
<DiscreteObjectKeyFrame KeyTime="0"> | ||
<DiscreteObjectKeyFrame.Value> | ||
<Visibility>Visible</Visibility> | ||
</DiscreteObjectKeyFrame.Value> | ||
</DiscreteObjectKeyFrame> | ||
</ObjectAnimationUsingKeyFrames> | ||
</Storyboard> | ||
</VisualState> | ||
<VisualState x:Name="ReadOnly"> | ||
<Storyboard> | ||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="EnabledBorder" Storyboard.TargetProperty="Visibility"> | ||
<DiscreteObjectKeyFrame KeyTime="0"> | ||
<DiscreteObjectKeyFrame.Value> | ||
<Visibility>Collapsed</Visibility> | ||
</DiscreteObjectKeyFrame.Value> | ||
</DiscreteObjectKeyFrame> | ||
</ObjectAnimationUsingKeyFrames> | ||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="DisabledOrReadonlyBorder" Storyboard.TargetProperty="Visibility"> | ||
<DiscreteObjectKeyFrame KeyTime="0"> | ||
<DiscreteObjectKeyFrame.Value> | ||
<Visibility>Visible</Visibility> | ||
</DiscreteObjectKeyFrame.Value> | ||
</DiscreteObjectKeyFrame> | ||
</ObjectAnimationUsingKeyFrames> | ||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="DisabledOrReadonlyBorder" Storyboard.TargetProperty="Background"> | ||
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneTextBoxBrush}" /> | ||
</ObjectAnimationUsingKeyFrames> | ||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="DisabledOrReadonlyBorder" Storyboard.TargetProperty="BorderBrush"> | ||
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneTextBoxBrush}" /> | ||
</ObjectAnimationUsingKeyFrames> | ||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="DisabledOrReadonlyContent" Storyboard.TargetProperty="Foreground"> | ||
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneTextBoxReadOnlyBrush}" /> | ||
</ObjectAnimationUsingKeyFrames> | ||
</Storyboard> | ||
</VisualState> | ||
</VisualStateGroup> | ||
<VisualStateGroup x:Name="FocusStates"> | ||
<VisualState x:Name="Focused"> | ||
<Storyboard> | ||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="EnabledBorder" Storyboard.TargetProperty="Background"> | ||
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneTextBoxEditBackgroundBrush}" /> | ||
</ObjectAnimationUsingKeyFrames> | ||
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="EnabledBorder" Storyboard.TargetProperty="BorderBrush"> | ||
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneTextBoxEditBorderBrush}" /> | ||
</ObjectAnimationUsingKeyFrames> | ||
</Storyboard> | ||
</VisualState> | ||
<VisualState x:Name="Unfocused"/> | ||
</VisualStateGroup> | ||
</VisualStateManager.VisualStateGroups> | ||
<Border x:Name="EnabledBorder" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" Margin="{StaticResource PhoneTouchTargetOverhang}" > | ||
<Grid Background="Transparent"> | ||
<ContentControl x:Name="WatermarkElement" BorderThickness="0" Padding="{TemplateBinding Padding}" | ||
HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" Margin="{StaticResource PhoneTextBoxInnerMargin}" | ||
Content="{TemplateBinding Watermark}" Style="{TemplateBinding WatermarkStyle}" | ||
Foreground="{TemplateBinding WatermarkForeground}"/> | ||
<ContentControl x:Name="ContentElement" BorderThickness="0" Padding="{TemplateBinding Padding}" | ||
HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" Margin="{StaticResource PhoneTextBoxInnerMargin}"/> | ||
</Grid> | ||
</Border> | ||
<Border x:Name="DisabledOrReadonlyBorder" Visibility="Collapsed" Background="Transparent" BorderBrush="{StaticResource PhoneDisabledBrush}" BorderThickness="{TemplateBinding BorderThickness}" Margin="{StaticResource PhoneTouchTargetOverhang}" > | ||
<TextBox x:Name="DisabledOrReadonlyContent" Text="{TemplateBinding Text}" Foreground="{StaticResource PhoneDisabledBrush}" Background="Transparent" | ||
SelectionBackground="{TemplateBinding SelectionBackground}" SelectionForeground="{TemplateBinding SelectionForeground}" | ||
TextWrapping="{TemplateBinding TextWrapping}" TextAlignment="{TemplateBinding TextAlignment}" IsReadOnly="True" Template="{StaticResource PhoneDisabledTextBoxTemplate}" | ||
FontFamily="{TemplateBinding FontFamily}" FontSize="{TemplateBinding FontSize}" FontWeight="{TemplateBinding FontWeight}" FontStyle="{TemplateBinding FontStyle}" /> | ||
</Border> | ||
</Grid> | ||
</ControlTemplate> | ||
</Setter.Value> | ||
</Setter> | ||
</Style> | ||
</ResourceDictionary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
using System; | ||
using System.Net; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using System.Windows.Documents; | ||
using System.Windows.Ink; | ||
using System.Windows.Input; | ||
using System.Windows.Media; | ||
using System.Windows.Media.Animation; | ||
using System.Windows.Shapes; | ||
|
||
namespace CS.Windows.Controls | ||
{ | ||
public class WatermarkTextBox : TextBox | ||
{ | ||
private Brush originalForeground; | ||
private ContentControl watermarkContent; | ||
|
||
public static readonly DependencyProperty WatermarkProperty = DependencyProperty.Register( "Watermark", typeof( string ), typeof( WatermarkTextBox ), null ); | ||
|
||
public static readonly DependencyProperty WatermarkStyleProperty = DependencyProperty.Register( "WatermarkStyle", typeof( Style ), typeof( WatermarkTextBox ), null ); | ||
|
||
public static readonly DependencyProperty WatermarkForegroundProperty = DependencyProperty.Register( "WatermarkForeground", typeof( Brush ), typeof( WatermarkTextBox ), null ); | ||
|
||
public static readonly DependencyProperty FocusedForegroundProperty = DependencyProperty.Register( "FocusedForeground", typeof( Brush ), typeof( WatermarkTextBox ), null ); | ||
|
||
public string Watermark | ||
{ | ||
get { return (string)GetValue( WatermarkProperty ); } | ||
set { SetValue( WatermarkProperty, value ); } | ||
} | ||
|
||
public Style WatermarkStyle | ||
{ | ||
get { return (Style)GetValue( WatermarkStyleProperty ); } | ||
set { SetValue( WatermarkStyleProperty, value ); } | ||
} | ||
|
||
public Brush WatermarkForeground | ||
{ | ||
get { return (Brush)GetValue( WatermarkForegroundProperty ); } | ||
set { SetValue( WatermarkForegroundProperty, value ); } | ||
} | ||
|
||
public Brush FocusedForeground | ||
{ | ||
get { return (Brush)GetValue( FocusedForegroundProperty ); } | ||
set { SetValue( FocusedForegroundProperty, value ); } | ||
} | ||
|
||
public WatermarkTextBox() | ||
{ | ||
DefaultStyleKey = typeof( WatermarkTextBox ); | ||
} | ||
|
||
public override void OnApplyTemplate() | ||
{ | ||
base.OnApplyTemplate(); | ||
originalForeground = Foreground; | ||
watermarkContent = (ContentControl)GetTemplateChild( "WatermarkElement" ); | ||
SetWatermarkVisibility(); | ||
} | ||
|
||
protected override void OnGotFocus( RoutedEventArgs e ) | ||
{ | ||
base.OnGotFocus( e ); | ||
|
||
SetWatermarkVisibility(); | ||
Foreground = FocusedForeground; | ||
} | ||
|
||
protected override void OnLostFocus( RoutedEventArgs e ) | ||
{ | ||
base.OnLostFocus( e ); | ||
|
||
SetWatermarkVisibility(); | ||
Foreground = originalForeground; | ||
} | ||
|
||
private void SetWatermarkVisibility() | ||
{ | ||
watermarkContent.Visibility = string.IsNullOrEmpty( Text ) ? Visibility.Visible : Visibility.Collapsed; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<Application | ||
x:Class="ExampleApp.WP7.App" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone" | ||
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"> | ||
|
||
<!--Application Resources--> | ||
<Application.Resources> | ||
</Application.Resources> | ||
|
||
<Application.ApplicationLifetimeObjects> | ||
<!--Required object that handles lifetime events for the application--> | ||
<shell:PhoneApplicationService | ||
Launching="Application_Launching" Closing="Application_Closing" | ||
Activated="Application_Activated" Deactivated="Application_Deactivated"/> | ||
</Application.ApplicationLifetimeObjects> | ||
|
||
</Application> |
Oops, something went wrong.