文本块内容被截断/未完全显示 [英] Textblock content truncated/not showing completely
问题描述
嗨
我的文本块内容有问题,内容没有完全显示。
每当我向上滚动时总是被截断。我试过增加textblock / scrollviewer hieght仍然是一样的
见下面的代码
xaml
<! - ContentPanel - 在此处添加其他内容 - >
< grid x:name =ContentPanelgrid.row =1margin =12,0,12,0 xmlns:x =#unknown>
< scrollviewer padding =10height =Autoverticalscrollbarvisibility =Auto>
< textblock x:name =textblocktextwrapping =Wrapforeground =Blackheight =Autofontsize =40>
xaml.cs
名称空间DevotionJson
{
公共部分类BibleInYear:PhoneApplicationPage
{
private List< bibledata>奉献;
公开BibleInYear()
{
InitializeComponent();
devotions = new List< bibledata>();
AddDevotions();
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
DateTime dt = DateTime.Now;
int month = dt .Month;
int year = dt.Year;
int index;
if(DateTime.IsLeapYear (年)||(月< = 2))
{
index = dt.DayOfYear - 1; //列表索引从0
}
else
{
index = dt.DayOfYear; //添加一天
}
textblock.Text = devotions [index] .ToString(); //或其他一些财产
}
private void AddDevotions()
{
for(int i = 1; i< = 366; i ++)
{
string filePath =BibleInYear / Bible+ i.ToString()+ .json;
BibleData d = ReadJsonFile(filePath);
devotions.Add(d);
}
}
公共BibleData ReadJsonFile(字符串JsonfilePath)
{
BibleData [] d = null ;
使用(StreamReader r = new StreamReader(JsonfilePath))
{
string json = r。 ReadToEnd();
d = JsonConvert.DeserializeObject< bibledata []>(json);
}
返回d [0]; < br $>
}
}
}
请帮助
Hi
I am having issues with my textblock content, the content does not show completely.
Whenever i scroll up is always truncated. i have tried increasing the textblock/scrollviewer hieght is still the same
see the code below
xaml
<!--ContentPanel - place additional content here-->
<grid x:name="ContentPanel" grid.row="1" margin="12,0,12,0" xmlns:x="#unknown">
<scrollviewer padding="10" height="Auto" verticalscrollbarvisibility="Auto">
<textblock x:name="textblock" textwrapping="Wrap" foreground="Black" height="Auto" fontsize="40">
xaml.cs
namespace DevotionJson
{
public partial class BibleInYear : PhoneApplicationPage
{
private List<bibledata> devotions;
public BibleInYear()
{
InitializeComponent();
devotions = new List<bibledata>();
AddDevotions();
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
DateTime dt = DateTime.Now;
int month = dt.Month;
int year = dt.Year;
int index;
if (DateTime.IsLeapYear(year) || (month <= 2))
{
index = dt.DayOfYear - 1; // list is indexed from 0
}
else
{
index = dt.DayOfYear; // add a day
}
textblock.Text = devotions[index].ToString(); // or some other property
}
private void AddDevotions()
{
for (int i = 1; i <= 366; i++)
{
string filePath = "BibleInYear/Bible" + i.ToString() + ".json";
BibleData d = ReadJsonFile(filePath);
devotions.Add(d);
}
}
public BibleData ReadJsonFile(string JsonfilePath)
{
BibleData[] d = null;
using (StreamReader r = new StreamReader(JsonfilePath))
{
string json = r.ReadToEnd();
d = JsonConvert.DeserializeObject<bibledata[]>(json);
}
return d[0];
}
}
}
Kindly help
推荐答案
如果数据很大,JSON反序列化会引起问题。尝试在Web配置中设置最大长度,如下所示。希望这可以解决问题。
If data is huge, JSON deserialize would cause issue. Try setting max length as shown below in web config. Hope this may resolve the issue.
<appSettings>
<add key="aspnet:MaxJsonDeserializerMembers" value="150000" />
</appSettings>
如何使用工具提示如果内容超出文本块的宽度。
How about using a tooltip if the content exceeds the width of the textblock.
这篇关于文本块内容被截断/未完全显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!