1
我有一個richtextbox的數據表單在其中。用戶可以鍵入一些文本並具有一定的編輯功能,但是我想讓用戶選擇將編輯器擴展爲全屏,以便擁有更多的richtextbox編輯選項。我怎樣才能實現一個功能,使我能夠全屏(或至少創建一個更大的窗口)的richtexteditor,讓用戶更好地瀏覽文檔和更多的編輯選項?Silverlight中的全屏richtextbox
這是在OOB模式下可以實現的。
我有一個richtextbox的數據表單在其中。用戶可以鍵入一些文本並具有一定的編輯功能,但是我想讓用戶選擇將編輯器擴展爲全屏,以便擁有更多的richtextbox編輯選項。我怎樣才能實現一個功能,使我能夠全屏(或至少創建一個更大的窗口)的richtexteditor,讓用戶更好地瀏覽文檔和更多的編輯選項?Silverlight中的全屏richtextbox
這是在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);
}
}
}
}
謝謝您的回覆我有幾個問題 - 您確保鍵盤是有限的 - 據我所知阿希什Shetty解釋在這個混合講話中:http://live.visitmix.com/MIX10/Sessions/CL10在SL4中,你有全面的鍵盤支持,而不是SL3中的限制。 另外。你確定如果它在一個數據表格中,richtextbox的大小調整會起作用嗎?它不會在數據表單內擴展嗎? – Jakob 2010-09-02 19:58:41
此外,這個問題是 - 通過設計我的應用程序不是那麼大,所以它只會爲積極選擇一個更大的工作區進行編輯的用戶 – Jakob 2010-09-02 20:26:12
@Peter Kiers - 我只是添加一個符號,所以你得到消息,我沒有試圖通過評論發送垃圾郵件:D感謝您的關注 – Jakob 2010-09-02 20:29:58