Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/295.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 文本块数据绑定错误_C#_Xaml_Windows Phone 8_Binding - Fatal编程技术网

C# 文本块数据绑定错误

C# 文本块数据绑定错误,c#,xaml,windows-phone-8,binding,C#,Xaml,Windows Phone 8,Binding,类文件: public class User { public string user { get; set; } } 文本块的XML: <DataTemplate x:Key="DataTemplate1"> <StackPanel x:Name="Stak" Orientation="Vertical" Width="0"> <TextBlock HorizontalAlignment="Left" TextWrapping=

类文件:

public class User
 {
   public string user { get; set; }
 }
文本块的XML:

<DataTemplate x:Key="DataTemplate1">
    <StackPanel x:Name="Stak" Orientation="Vertical" Width="0">
        <TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="{Binding}" Width="443" Margin="0,0,-443,0" FontSize="22"/>
        <TextBlock x:Name="UserText" HorizontalAlignment="Left" Text="{Binding User}" TextWrapping="NoWrap" Width="443" Margin="0,0,-443,0" FontFamily="Segoe WP SemiLight" FontSize="23"/>
    </StackPanel>
 </DataTemplate>
因此,基本上,这应该是当应用程序加载时,它从用户信息文件夹中读取一个文件,并将其添加到文本块文本中。因为我无法访问TextBlock,因为它位于Pivot数据模板中,所以我将其绑定


一旦应用程序读取完文件,就意味着要将
名称
中的任何内容添加到文本块中,但它没有这样做。

@Ahmed.C,
是否显示类型名称?@dkozl你是什么意思?你看到什么了吗?如果绑定上下文很好,则
Text=“{binding}”
应在对象上调用
ToString()
,默认情况下将返回类名,类似于
MyNamespace.User
当我运行应用程序时,文本块为空。我试图让名为“UserText”的文本块显示文本,而不是像你所知道的那样显示关于我们的文本。
IsolatedStorageFileStream readName = store.OpenFile("/User Information/UserName.txt", FileMode.Open, FileAccess.Read);
using (StreamReader contactName = new StreamReader(readName))
  {
    var name = contactName.ReadLine();
    var Load = new User();
    Load.user = name;
  }