J'essaie de créer un contrôle de zone de texte personnalisé pour mon application WP7. Fondamentalement, je veux qu'il ait une fonction GotFocus et je voudrais être en mesure de le faire ont un certain nombre InputScopewp7: Contrôle personnalisé avec fonctions
J'utilise les ressources suivantes que ma base pour essayer de créer une zone de texte contrôle personnalisé:
- http://www.windowsphonegeek.com/articles/WP7-WatermarkedTextBox-custom-control
- http://www.windowsphonegeek.com/articles/Creating-a-WP7-Custom-Control-in-7-Steps
Je peux obtenir la zone de texte à afficher dans mon application, mais je ne peux pas l'appel GotFocus à travailler sans avoir la fonction dans l'application (qui contrecarre le but).
La fonction GotFocus que j'appellerais normalement est également dans la classe de la génériqueTextbox. Comment j'appellerais le GotFocus et l'InputScope?
Le ResourceDictionary est le suivant:
<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:local="clr-namespace:wp7CustomControlsLibrary">
<Style TargetType="local:genericTextbox">
<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="Template">
<Setter.Value>
<ControlTemplate TargetType="local:genericTextbox">
<Grid Background="Transparent">
<Border x:Name="EnabledBorder" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Margin="{StaticResource PhoneTouchTargetOverhang}">
<Grid>
<ContentControl x:Name="ContentElement" BorderThickness="0" HorizontalContentAlignment="Stretch" Margin="{StaticResource PhoneTextBoxInnerMargin}" Padding="{TemplateBinding Padding}" VerticalContentAlignment="Stretch"/>
</Grid>
</Border>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>