1

その中にリッチテキストボックスを含むデータフォームがあります。ユーザーはテキストを入力して編集することもできますが、エディターをフルスクリーンに拡張してリッチテキストボックスの編集オプションを増やすオプションをユーザーに提供したいと思います。Richtexteditor を全画面表示 (または少なくとも大きなウィンドウを作成) できる機能を実装して、ユーザーがドキュメントの全体像を把握し、より多くの編集オプションを利用できるようにするにはどうすればよいですか?

これは OOB モードで可能です。

4

1 に答える 1

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);
            }
        }
    }
}
于 2010-09-02T17:18:20.103 に答える