文本块内容未完全显示 [英] Textblock content not showing completely
问题描述
你好
我的文本块内容有问题,内容没有完全显示。
每当我向上滚动时总会留下一些文字。我试过增加textblock / scrollviewer hieght。
见下图
Hi
I am having issues with my textblock content, the content does not show completely.
Whenever i scroll up is always leaves some text out. i have tried increasing the textblock/scrollviewer hieght.
see the image below
请参阅以下代码
xaml
<! - ContentPanel - 在此处添加其他内容 - >
&NBSP; &NBSP; &NBSP; < Grid x:Name =" ContentPanel" Grid.Row = QUOT 1 QUOT;保证金=" 12,0,12,0>>
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; < ScrollViewer Padding =" 10"高度= QUOT;自动" VerticalScrollBarVisibility =" Auto">
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; < TextBlock x:Name =" textblock" TextWrapping = QUOT;包覆与QUOT;前景= QUOT;黑色"高度= QUOT;自动"字号= QUOT; 40" />
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; < / ScrollViewer>
&NBSP; &NBSP; &NBSP; < / Grid>
$
xaml.cs
命名空间DevotionJson
{
&NBSP;公共部分课程BibleInYear:PhoneApplicationPage
&NBSP; {
$
&NBSP; &NBSP; &NBSP;私人清单< BibleData>奉献;
&NBSP; &NBSP; &NBSP;公共BibleInYear()
&NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; InitializeComponent();
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; devotions = new List< BibleData>();
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; AddDevotions(); &NBSP;
&NBSP; &NBSP; &NBSP; }
&NBSP; &NBSP; &NBSP; protected override void OnNavigatedTo(NavigationEventArgs e)
&NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; DateTime dt = DateTime.Now;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; int month = dt.Month;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; int year = dt.Year;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; int index;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; if(DateTime.IsLeapYear(year)||(month< = 2))
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; index = dt.DayOfYear - 1; //列表的索引编号为0
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;否则
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; index = dt.DayOfYear; //添加一天
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; textblock.Text = devotions [index] .ToString(); //或其他一些财产
&NBSP; &NBSP; &NBSP; }
&NBSP; &NBSP; &NBSP; private void AddDevotions()
&NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; for(int i = 1; i< = 366; i ++)
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; string filePath =" BibleInYear / Bible" + i.ToString()+" .json";
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; BibleData d = ReadJsonFile(filePath);
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; devotions.Add(d);
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; }
&NBSP; &NBSP; &NBSP; public BibleData ReadJsonFile(string JsonfilePath)
&NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; BibleData [] d = null;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP;使用(StreamReader r = new StreamReader(JsonfilePath))
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; string json = r.ReadToEnd();
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; d = JsonConvert.DeserializeObject< BibleData []>(json);
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;返回d [0];
&NBSP; &NBSP; &NBSP; }
&NBSP; }
}
$
请帮助
see the code below
xaml
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<ScrollViewer Padding="10" Height="Auto" VerticalScrollBarVisibility="Auto">
<TextBlock x:Name="textblock" TextWrapping="Wrap" Foreground="Black" Height="Auto" FontSize="40" />
</ScrollViewer>
</Grid>
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
Jayjay john
Jayjay john
推荐答案
我会给scrollviewer一个特定的高度而不是auto ie(800)。 如果文本仍然在顶部稍微剪切,我还会尝试在文本块上设置上边距
I would give the scrollviewer a specific height instead of auto ie (800). I would also try setting a top margin on the textblock if the text is still cut off a little at the top
这篇关于文本块内容未完全显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!