我有一个自定义的WPF键盘,用于在应用程序中输入
xmlns:WpfKb="clr-namespace:WpfKb.Controls;assembly=WpfKb"
在资源字典中
<WpfKb:OnScreenKeypad x:Key="OnScreenKeypad"/>
在我的XAML代码中,我使用以下代码来激活:
<TextBox Name="Sensor1Yoffset" Width="100" Margin="5,0" Grid.Row="1" Grid.Column="2" Style="{DynamicResource PmEditTextBox}" Text="{Binding Path=SensorOffsetY1}" VerticalContentAlignment="Center" HorizontalContentAlignment="Center"
WpfKb:FloatingTouchScreenKeyboard.KeyboardType="{StaticResource OnScreenKeypad}"
WpfKb:FloatingTouchScreenKeyboard.OpenOnFocus="False"
WpfKb:FloatingTouchScreenKeyboard.OpenOnMouseClick="{Binding Path=UseOnScreenKeyboard}"
WpfKb:FloatingTouchScreenKeyboard.Placement="Left"
WpfKb:FloatingTouchScreenKeyboard.PlacementTarget="{Binding ElementName=TheGui}" Grid.ColumnSpan="1" />
现在我需要在后面的代码中添加这个,但不知道ro从哪里开始寻找。
TextBox ChannelName = new TextBox();
ChannelName.Style = (MyView.TryFindResource("PmEditTextBox") as Style);
ChannelName.Width = 300;
FloatingTouchScreenKeyboardclass定义为
public partial class FloatingTouchScreenKeyboard : System.Windows.Controls.Primitives.Popup
{
public static readonly DependencyProperty AreAnimationsEnabledProperty = DependencyProperty.Register("AreAnimationsEnabled", typeof(bool), typeof(FloatingTouchScreenKeyboard), new UIPropertyMetadata(true));
public static readonly DependencyProperty IsAllowedToFadeProperty = DependencyProperty.Register("IsAllowedToFade", typeof(bool), typeof(FloatingTouchScreenKeyboard), new UIPropertyMetadata(true));
public static readonly DependencyProperty IsDraggingProperty = DependencyProperty.Register("IsDragging", typeof(bool), typeof(FloatingTouchScreenKeyboard), new UIPropertyMetadata(false));
public static readonly DependencyProperty IsDragHelperAllowedToHideProperty = DependencyProperty.Register("IsDragHelperAllowedToHide", typeof(bool), typeof(FloatingTouchScreenKeyboard), new UIPropertyMetadata(false));
public static readonly DependencyProperty IsKeyboardShownProperty = DependencyProperty.Register("IsKeyboardShown", typeof(bool), typeof(FloatingTouchScreenKeyboard), new UIPropertyMetadata(true));
public static readonly DependencyProperty MaximumKeyboardOpacityProperty = DependencyProperty.Register("MaximumKeyboardOpacity", typeof(double), typeof(FloatingTouchScreenKeyboard), new UIPropertyMetadata(0.9d));
public static readonly DependencyProperty MinimumKeyboardOpacityProperty = DependencyProperty.Register("MinimumKeyboardOpacity", typeof(double), typeof(FloatingTouchScreenKeyboard), new UIPropertyMetadata(0.2d));
public static readonly DependencyProperty KeyboardHideDelayProperty = DependencyProperty.Register("KeyboardHideDelay", typeof(double), typeof(FloatingTouchScreenKeyboard), new UIPropertyMetadata(5d));
public static readonly DependencyProperty KeyboardHideAnimationDurationProperty = DependencyProperty.Register("KeyboardHideAnimationDuration", typeof(double), typeof(FloatingTouchScreenKeyboard), new UIPropertyMetadata(0.5d));
public static readonly DependencyProperty KeyboardShowAnimationDurationProperty = DependencyProperty.Register("KeyboardShowAnimationDuration", typeof(double), typeof(FloatingTouchScreenKeyboard), new UIPropertyMetadata(0.5d));
public static readonly DependencyProperty DeadZoneProperty = DependencyProperty.Register("DeadZone", typeof(double), typeof(FloatingTouchScreenKeyboard), new UIPropertyMetadata(5d));
如有任何建议,我们将不胜感激。
您正在设置的大多数附加属性实际上是由浮动键盘的基类Popup
公开的。Popup
类具有setter方法,可用于从C#代码设置属性,例如:
Popup.SetPlacementTarget(ChannelName, TheGui)
对于具有绑定的属性,请使用目标的SetBinding
方法:
ChannelName.SetBinding(
Popup.OpenOnMouseClickProperty,
new Binding
{
Path = new PropertyPath("UseOnScreenKeyboard")
});
查看WpfKb项目,我没有看到KeyboardType
属性的任何定义。也许它存在于早期版本中,或者您使用的是定制/分叉版本?