【问题标题】:Event trigger not working on RichEditBox XAML-C# windows 8事件触发器在 RichEditBox XAML-C# windows 8 上不起作用
【发布时间】:2013-10-22 16:29:11
【问题描述】:

我正在使用带有 XAML 和 C# 的 RichEditBox 我在 XAML 中有以下 3 个事件,在 C#(返回代码)中有相应的处理程序

DoubleTapped="RichEditBox_DoubleTapped" RightTapped="RichEditBox_RightTapped" PointerReleased="RichEditBox_PointerReleased"

但是在放置调试点后,我发现它们都没有被触发。

如果我不是双击单词而是双击 RichEditBox 中的空白区域,则会触发 DoubleTapped 事件。处理此事件后,双击甚至开始对单词起作用。

我需要处理上述任何关于文字的事件。但他们都没有像预期的那样做出回应。 我怎样才能实现它?

【问题讨论】:

  • 我有:IsHoldingEnabled="True" IsDoubleTapEnabled="True" IsRightTapEnabled="True"

标签: c# event-handling winrt-xaml


【解决方案1】:

好吧。有其他 2 个事件作为:

SelectionChanged="RichEditBox_SelectionChanged" Holding="RichEditBox_Holding"

问题中提到的上述事件可能是一个错误,但不确定。

【讨论】:

    【解决方案2】:

    这是一个用户控件,我有这个代码 XAML:

    <RichEditBox x:Name="TextElementControl" Background="{Binding Background, ElementName=userControlModified}" ManipulationMode="None" ScrollViewer.HorizontalScrollMode="Disabled"
                        AcceptsReturn="True" TextWrapping="Wrap"
                        SizeChanged="TextElementControlSizeChanged"  
                        IsDoubleTapEnabled="False" DoubleTapped="TextElementControl_DoubleTapped" BorderThickness="0" BorderBrush="{x:Null}" Padding="10,10,10,10"/>
    

    在后面的代码中:

    private void TextElementControl_DoubleTapped(object sender, DoubleTappedRoutedEventArgs e)
            {
                //log message, breakpoint is hitting this during double click.
            }
    

    在我们设置的代码的某些部分

    void ControlLoaded(object sender, RoutedEventArgs e) 
            {  
        TextElementControl.IsReadOnly = false;
    }
    

    它有效,我希望它可以帮助你。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-10
      • 1970-01-01
      • 1970-01-01
      • 2013-01-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多