silverlight中的全屏richtextbox

silverlight中的全屏richtextbox,silverlight,richtextbox,fullscreen,rich-text-editor,silverlight-oob,Silverlight,Richtextbox,Fullscreen,Rich Text Editor,Silverlight Oob,我有一个带有richtextbox的数据表单。用户可以键入一些文本并具有一些编辑功能,但我想给用户一个选项,将编辑器扩展到全屏,以拥有更多richtextbox编辑选项。我如何实现一个功能,允许我全屏(或至少创建一个更大的窗口)richtexteditor,以便用户对文档有更好的概述和更多的编辑选项 这在OOB模式下是可能的。全屏无法工作,因为您限制了全屏键盘输入: 向上箭头 向下箭头 左箭头 右箭头 空格键 标签 翻页 翻页 家 结束 进入 例如,您可以通过将元素设置为RootVisual

我有一个带有richtextbox的数据表单。用户可以键入一些文本并具有一些编辑功能,但我想给用户一个选项,将编辑器扩展到全屏,以拥有更多richtextbox编辑选项。我如何实现一个功能,允许我全屏(或至少创建一个更大的窗口)richtexteditor,以便用户对文档有更好的概述和更多的编辑选项


这在OOB模式下是可能的。

全屏无法工作,因为您限制了全屏键盘输入:

  • 向上箭头
  • 向下箭头
  • 左箭头
  • 右箭头
  • 空格键
  • 标签
  • 翻页
  • 翻页
  • 结束
  • 进入
例如,您可以通过将元素设置为RootVisual的精确大小,并调整边距以将其正确放置在应用程序中,从而使元素填充silverlight应用程序的整个空间:

XAML:

<UserControl x:Class="SilverlightApplication1.MyRichTextBox"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">

<Grid x:Name="LayoutRoot" Background="White">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="*" />
    </Grid.RowDefinitions>
    <Button x:Name="FullScreen" Grid.Row="0" Content="FullScreen" Click="FullScreen_Click"  />
    <RichTextBox Grid.Row="1" />
</Grid>
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;

namespace SilverlightApplication1
{
    public partial class MyRichTextBox : UserControl
    {
        private Thickness _oldMargin;
        private double _oldHeight = double.NaN;
        private double _oldWidth = double.NaN;
        private HorizontalAlignment _oldHorizontalAlignment;
        private VerticalAlignment _oldVerticalAlignment;
        private bool _fullScreen = false;

        public MyRichTextBox()
        {
            InitializeComponent();
        }

        private void FullScreen_Click(object sender, RoutedEventArgs e)
        {
            if (_fullScreen)
            {
                _fullScreen = false;
                Margin = _oldMargin;
                Width = _oldWidth;
                Height = _oldHeight;
            }
            else
            {
                _fullScreen = true;

                _oldMargin = Margin;
                _oldWidth = Width;
                _oldHeight = Height;
                _oldHorizontalAlignment = HorizontalAlignment;
                _oldVerticalAlignment = VerticalAlignment;

                FrameworkElement rootVisual = Application.Current.RootVisual as FrameworkElement;
                GeneralTransform generalTransform = TransformToVisual(rootVisual);

                Point position = generalTransform.Transform(new Point(0, 0));
                Width = rootVisual.ActualWidth;
                Height =rootVisual.ActualHeight;

                Margin = new Thickness(-position.X - 1, -position.Y - 1
                  , (ActualWidth + position.X) - rootVisual.ActualWidth - 1
                  , (ActualHeight + position.Y) - rootVisual.ActualHeight - 1);
            }
        }
    }
}

全屏无法工作,因为您限制了全屏键盘输入:

  • 向上箭头
  • 向下箭头
  • 左箭头
  • 右箭头
  • 空格键
  • 标签
  • 翻页
  • 翻页
  • 结束
  • 进入
例如,您可以通过将元素设置为RootVisual的精确大小,并调整边距以将其正确放置在应用程序中,从而使元素填充silverlight应用程序的整个空间:

XAML:

<UserControl x:Class="SilverlightApplication1.MyRichTextBox"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">

<Grid x:Name="LayoutRoot" Background="White">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="*" />
    </Grid.RowDefinitions>
    <Button x:Name="FullScreen" Grid.Row="0" Content="FullScreen" Click="FullScreen_Click"  />
    <RichTextBox Grid.Row="1" />
</Grid>
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;

namespace SilverlightApplication1
{
    public partial class MyRichTextBox : UserControl
    {
        private Thickness _oldMargin;
        private double _oldHeight = double.NaN;
        private double _oldWidth = double.NaN;
        private HorizontalAlignment _oldHorizontalAlignment;
        private VerticalAlignment _oldVerticalAlignment;
        private bool _fullScreen = false;

        public MyRichTextBox()
        {
            InitializeComponent();
        }

        private void FullScreen_Click(object sender, RoutedEventArgs e)
        {
            if (_fullScreen)
            {
                _fullScreen = false;
                Margin = _oldMargin;
                Width = _oldWidth;
                Height = _oldHeight;
            }
            else
            {
                _fullScreen = true;

                _oldMargin = Margin;
                _oldWidth = Width;
                _oldHeight = Height;
                _oldHorizontalAlignment = HorizontalAlignment;
                _oldVerticalAlignment = VerticalAlignment;

                FrameworkElement rootVisual = Application.Current.RootVisual as FrameworkElement;
                GeneralTransform generalTransform = TransformToVisual(rootVisual);

                Point position = generalTransform.Transform(new Point(0, 0));
                Width = rootVisual.ActualWidth;
                Height =rootVisual.ActualHeight;

                Margin = new Thickness(-position.X - 1, -position.Y - 1
                  , (ActualWidth + position.X) - rootVisual.ActualWidth - 1
                  , (ActualHeight + position.Y) - rootVisual.ActualHeight - 1);
            }
        }
    }
}

谢谢你的回复我有几个问题-你确定键盘是有限的吗-据我所知Ashish Shetty在这篇混音演讲中解释说:在SL4中,你有完整的键盘支持,而不是SL3中的有限。也。如果richtextbox位于数据表单中,是否确实可以调整其大小?它不会在数据表单内部扩展吗?这个问题的另一个补充是——根据设计,我的应用程序没有那么大,所以它只适用于主动选择更大工作空间的用户editing@Peter基尔斯-我会加上一个at标志让你明白,我不是想用评论来发垃圾邮件:D谢谢你的关注键盘限制在浏览器外被删除,权限提升()。我刚刚用SL4应用程序测试了它,但在其他方面仍然有限制。它甚至会在dataform中扩展(尽管未测试),因为我将元素的边距设置为负值。如果你只想要半个屏幕或者更多的屏幕,你也应该能够自己调整大小。@Peter Kiers-我试过了,看起来它可以突破数据表单的边界,但是,y数据表单包含在一个tabcontrol中-你知道如何突破tabcontrol吗。如果它在一个新的窗口中,只要它在应用程序的其他部分之前就可以了。谢谢你的回答。我有几个问题-你确定键盘是有限的吗-据我所知Ashish Shetty在这篇混音演讲中解释说:在SL4中,你有完整的键盘支持,而不是在SL3中。也。如果richtextbox位于数据表单中,是否确实可以调整其大小?它不会在数据表单内部扩展吗?这个问题的另一个补充是——根据设计,我的应用程序没有那么大,所以它只适用于主动选择更大工作空间的用户editing@Peter基尔斯-我会加上一个at标志让你明白,我不是想用评论来发垃圾邮件:D谢谢你的关注键盘限制在浏览器外被删除,权限提升()。我刚刚用SL4应用程序测试了它,但在其他方面仍然有限制。它甚至会在dataform中扩展(尽管未测试),因为我将元素的边距设置为负值。如果你只想要半个屏幕或者更多的屏幕,你也应该能够自己调整大小。@Peter Kiers-我试过了,看起来它可以突破数据表单的边界,但是,y数据表单包含在一个tabcontrol中-你知道如何突破tabcontrol吗。如果它在一个新的窗口中,只要它在应用程序的其余部分之前就可以了。