我正在開發一個silverlight 5應用程序。動態加載控件時TextWrapping不起作用
因爲我們正在使用網格分割控件來使2個主面板更加靈活。 如果我們嘗試在xaml的第一個面板中使用textblock,並在其旁邊設置gridspliter,它就可以正常工作。
但是,通過代碼在文本塊的TextWrapping之後添加相同的文本塊不能正常工作。
我們增加了從後面的代碼,因爲我們需要與這一點,添加一個圖像相同的所有數據來動態:
找到下面的代碼:
<StackPanel x:Name="stkRelatedEntity" Grid.Column="0" Grid.Row="1">
HyperlinkButton hyltest = new HyperlinkButton();
StackPanel stk = new StackPanel();
stk.Orientation = Orientation.Horizontal;
Image RImage = new Image();
if (relatedEntity.Image != null)
{
RImage.Source = Common.GetBitMap((byte[])relatedEntity.Image);
RImage.Height = 16;
RImage.Width = 16;
}
TextBlock RText = new TextBlock();
RText.Text = relatedEntity.DisplayNameN;
RText.TextWrapping = TextWrapping.Wrap;
RText.MaxWidth = 250;
RText.MinWidth = 10;
stk.Children.Add(RImage);
stk.Children.Add(RText);
hyltest.Content = stk;
stkRelatedEntity.Children.Add(hykInfo);