[英]textblock text croped in 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 = 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);
}
}
}
只需從代碼中刪除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);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.