Silverlight,旋转文本框时并非所有文本都显示
我有一个自定义控件,其中有一个文本框,可以旋转,具体取决于您希望它折叠还是展开,当它折叠时,我希望文本框是垂直的,当它展开时,我希望它水平。
问题是,当它是垂直的时,文本框不会显示所有文本,我一直在寻找答案,并且我知道这与 silverlight 更新其布局的方式有关。这是我的代码
private void CollapseControl()
{
CollapseCommand.Content = "E";
CollapseCommand.Margin = _btnMarginOnCollapse;
BtnZoomIn.Visibility = Visibility.Collapsed;
BtnZoomOut.Visibility = Visibility.Collapsed;
ScrollViewerStackPanel.Visibility = Visibility.Collapsed;
ZoomPanel.Visibility = Visibility.Collapsed;
this.HorizontalAlignment = HorizontalAlignment.Left;
this.Width = 40;
RotateTransform nameRotateTransform = new RotateTransform();
nameRotateTransform.Angle = 270;
Nametb.RenderTransform = nameRotateTransform;
Nametb.VerticalAlignment = VerticalAlignment.Bottom;
Nametb.Height = Nametb.Width;
Nametb.Width = Nametb.Height;
Nametb.UpdateLayout();
}
I have a custom control an inside of it I have a textbox that rotates depending wether you'd like it to collapse or expand, when it is collapsed I want the textbox to be vertical and when it is expanded I want it horizontal.
The problem is that when it is vertical the textbox doesn't show all the text, I've being looking for an answer, and I understand it has to do with the way silverlight updates it's layout. Here is my code
private void CollapseControl()
{
CollapseCommand.Content = "E";
CollapseCommand.Margin = _btnMarginOnCollapse;
BtnZoomIn.Visibility = Visibility.Collapsed;
BtnZoomOut.Visibility = Visibility.Collapsed;
ScrollViewerStackPanel.Visibility = Visibility.Collapsed;
ZoomPanel.Visibility = Visibility.Collapsed;
this.HorizontalAlignment = HorizontalAlignment.Left;
this.Width = 40;
RotateTransform nameRotateTransform = new RotateTransform();
nameRotateTransform.Angle = 270;
Nametb.RenderTransform = nameRotateTransform;
Nametb.VerticalAlignment = VerticalAlignment.Bottom;
Nametb.Height = Nametb.Width;
Nametb.Width = Nametb.Height;
Nametb.UpdateLayout();
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
一种解决方案是使用 Silverlight 工具包LayoutTransformer 控件>。
您将现有的文本块包装在
LayoutTransformer
中然后您的代码如下所示:-
One solution would be to use the
LayoutTransformer
control from the Silverlight toolkit.You wrap the existing textblock inside a
LayoutTransformer
Then your code looks like:-
我最近遇到了类似的问题,并提出了以下解决方案(基于 Silverlight 论坛上的帖子),这也应该有助于解决您的问题:
I just recently ran into a similar problem, and came up with the following solution (based on a post on the Silverlight forums), which should help with your issue, too:
我刚刚写了以下内容,我的类似问题就解决了。
I just written following and my similar problem is solved.