C# 文本块在windows phone中出现的文本

C# 文本块在windows phone中出现的文本,c#,windows-phone-7,windows-phone-8,windows-phone,C#,Windows Phone 7,Windows Phone 8,Windows Phone,我的文本块宽度有问题。我的列表框中有一条很长的文本。问题是我的文本从右侧被截取。请看一下屏幕截图。帮帮我 我的示例代码在这里 TextBlock tbl = new TextBlock(); tbl.Text = "Date : " + col.Value; tbl.Width = 460; tbl.MaxWidth = 460; tbl.Height = 50; tbl.Margin = new Thickness(35, 0, 0, 0); tbl.TextWrapping = TextWr

我的文本块宽度有问题。我的列表框中有一条很长的文本。问题是我的文本从右侧被截取。请看一下屏幕截图。帮帮我

我的示例代码在这里

TextBlock tbl = new TextBlock();
tbl.Text = "Date : " + col.Value;
tbl.Width = 460;
tbl.MaxWidth = 460;
tbl.Height = 50;
tbl.Margin = new Thickness(35, 0, 0, 0);
tbl.TextWrapping = TextWrapping.Wrap;
tbl.TextAlignment = TextAlignment.Left;
tbl.Foreground = new SolidColorBrush(Color.FromArgb(255, 131, 72, 7));

LsUtsav.Items.Add(tbl);
在Xaml文件中

<controls:PanoramaItem x:Name="putsav" Header="Utsav">
            <controls:PanoramaItem.HeaderTemplate>
                <DataTemplate>
                    <TextBlock TextWrapping="Wrap" Text="{Binding Content, RelativeSource={RelativeSource TemplatedParent}}" FontSize="65" Margin="0,0,0,30" Foreground="#FF5F3D14" />
                </DataTemplate>
            </controls:PanoramaItem.HeaderTemplate>

            <ListBox Height="520" Margin="20,-50,9,34" Name="LsUtsav" HorizontalAlignment="Center" VerticalAlignment="Bottom" Foreground="#FF9E4E0E" FontSize="24" Width="460" >

            </ListBox>

            <!--Double line list with image placeholder and text wrapping-->

        </controls:PanoramaItem>

我解析xml文件并将其绑定到我的列表框中

XDocument xdoc = XDocument.Parse(e.Result, LoadOptions.None);

            int d = xdoc.Descendants("KalyanPushti").Nodes().Count();
            //BtnFuture.Content = "Future (" + d + ")";
            putsav.Header = "Utsav (" + d + ")";
            LsUtsav.Items.Clear();
            if (d == 0)
            {
                LsUtsav.Items.Add("No Events");
            }
            else
            {
                LsUtsav.Items.Clear();
            //    BtnFuture.Content = "Future (" + d + ")";
                putsav.Header = "Utsav (" + d + ")";

                var summ = xdoc.Descendants("pushti");
                foreach (var col in summ.Elements())
                {
                    if (col.Name == "utsavlist")
                    {

                        TextBlock tbl = new TextBlock();
                        tbl.Text = col.Value;
                      //  tbl.FontFamily = new FontFamily("verdana");
                        tbl.Width = 470;

                        if (col.Value.Count() <= 35)
                        {
                            tbl.Height = 40;
                        }
                        else
                        {
                            tbl.Height = 80;
                        }
                        tbl.FontSize = 24;
                        tbl.Margin = new Thickness(35,0,0,0);
                        tbl.TextWrapping = TextWrapping.Wrap;
                        tbl.TextAlignment = TextAlignment.Left;
                        tbl.Foreground = new SolidColorBrush(Color.FromArgb(255, 131, 17, 17));
                        LsUtsav.Items.Add(tbl);
                    }
                    else if (col.Name == "date")
                    {
                        TextBlock tbl = new TextBlock();
                        tbl.Text = "Date : " + col.Value;
                        tbl.Width = 460;
                        tbl.MaxWidth = 460;
                        tbl.Height = 50;
                        tbl.Margin = new Thickness(35, 0, 0, 0);
                        tbl.TextWrapping = TextWrapping.Wrap;
                        tbl.TextAlignment = TextAlignment.Left;
                        LsUtsav.Foreground = new SolidColorBrush(Color.FromArgb(255, 131, 72, 7));


                        LsUtsav.Items.Add(tbl);



                    }
                    else
                    {
                        TextBlock tbl = new TextBlock();
                        tbl.Text = col.Value;
                        tbl.Width = 460;
                        tbl.Margin = new Thickness(35, 0, 0, 0);
                        tbl.TextWrapping = TextWrapping.Wrap;
                        tbl.TextAlignment = TextAlignment.Left;
                        LsUtsav.Foreground = new SolidColorBrush(Color.FromArgb(255, 131, 72, 7));
                        LsUtsav.Items.Add(tbl);

                    }

                }

            }
XDocument xdoc=XDocument.Parse(例如,Result,LoadOptions.None);
int d=xdoc.substands(“KalyanPushti”).Nodes().Count();
//BtnFuture.Content=“未来(+d+”);
putsav.Header=“Utsav”(+d+”);
LsUtsav.Items.Clear();
如果(d==0)
{
LsUtsav.Items.Add(“无事件”);
}
其他的
{
LsUtsav.Items.Clear();
//BtnFuture.Content=“未来(+d+”);
putsav.Header=“Utsav”(+d+”);
var sum=xdoc.后代(“pushti”);
foreach(summ.Elements()中的var col)
{
如果(列名称==“utsavlist”)
{
TextBlock tbl=新的TextBlock();
tbl.Text=列值;
//tbl.FontFamily=新FontFamily(“verdana”);
tbl.宽度=470;

如果(col.Value.Count()只需从代码中删除
MaxWidth
Height
Width
,然后重试

TextBlock tbl = new TextBlock();
tbl.Text = "Date : " + col.Value;
tbl.Height = 100;
tbl.Width = 400;
tbl.Margin = new Thickness(35, 0, 0, 0);
tbl.TextWrapping = TextWrapping.Wrap;
tbl.TextAlignment = TextAlignment.Left;
LsUtsav.Foreground = new SolidColorBrush(Color.FromArgb(255, 131, 72, 7));
Mylist.Items.Add(tbl);

不要在过程代码中创建或操作UI元素。这就是XAML的用途。你想要它被包装或滚动吗?谢谢你的回答。我想要它被包装。那么不要设置宽度?@VivekParikh-从
列表框
控件中去掉
宽度
属性,看看这是否能修复它。另外,你应该在你的c中添加@keyboardP如果在此处回复我,请注意,因为此评论线程中有多人,因此如果您不这样做,我将不会得到通知:)请从代码中删除高度,如果不起作用,请尝试。然后,将高度更改为100或更高。