【问题标题】:Binding Error in my windows phone 8 project我的 windows phone 8 项目中的绑定错误
【发布时间】:2014-03-15 12:39:22
【问题描述】:

好吧,我正在尝试在长列表中进行简单的绑定,但是模拟器在

中抛出了一个调试异常

private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)

我会在下面粘贴我的代码

我的模型类是

public class CommentView
{
    public string ID { get; set; }
    public string IsApproved { get; set; }
    public string PostersComment { get; set; }
    public string Name { get; set; }  //Note that this is the name of the Jizuser
    public string PostedDate { get; set; }
    public string PostedTime { get; set; }
}

我正在通过 xaml csharp 代码进行绑定。所以脚本粘贴在下面

 List<CommentView> commenterContainer = new List<CommentView>();
 commenterContainer.Add(new CommentView() { Name ="FEMI", IsApproved="True", ID="1", PostedDate="2/3/2014", PostedTime="01:02:2011", PostersComment= "Me" });
 commenterlist.ItemsSource = commenterContainer;

这是入围项目。我是如何制作 dataItem 模板的

<phone:LongListSelector Margin="3"  x:Name="commenterlist" SelectionChanged ="Bloglist_SelectionChanged" Grid.Row="6"
                                Background="White">
                <phone:LongListSelector.ItemTemplate>
                    <DataTemplate>
                        <Border BorderThickness="1" BorderBrush="#4063A9">
                            <StackPanel Margin="10,10,10,10" Orientation="Vertical" >
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock x:Name="{Binding ID}" Visibility="Collapsed"/>


                                    <Image Source="/Assets/profile.jpg"/>
                                    <TextBlock Text="{Binding Name}" TextWrapping="Wrap" Margin="12,20,0,0" Style="{StaticResource PhoneTextNormalStyle}"   HorizontalAlignment="Left" VerticalAlignment="Center"  Foreground="#4063A9"/>
                                </StackPanel>

                                <TextBlock Text="{Binding PostersComment}"  Margin="12,-6,0,0" Style="{StaticResource PhoneTextSubtleStyle}"  TextWrapping="Wrap" />

                                <StackPanel Orientation="Horizontal">
                                    <TextBlock x:Name="{Binding PostedDate}"  />
                                    <TextBlock x:Name="{Binding PostedTime}" />
                                    <TextBlock x:Name="{Binding IsApproved}" Visibility="Collapsed"/>
                                </StackPanel>

                            </StackPanel>
                        </Border>
                    </DataTemplate>
                </phone:LongListSelector.ItemTemplate>
            </phone:LongListSelector>

【问题讨论】:

  • 向我们提供来自 e 参数的异常消息
  • 好的,我想等一下。感谢您的回复
  • 可悲的是 Vs 没有向我显示错误。它只是在 App.xaml.cs 文件中放置一个断点。在 Debugger.Break();它位于 Application_UnhandledException 方法中。我真的不知道异常是什么,但我知道这是我的绑定问题
  • 未处理异常事件中的事件arg没有异常?失败的绑定通常只是向调试控制台报告。
  • 好的,所以我应该过去调试控制台的内容

标签: c# xaml data-binding windows-phone-8 binding


【解决方案1】:

问题来自 LongListSelector

重新创建 LongListSelector 解决了这个问题。我这样做了,效果很好

【讨论】:

    猜你喜欢
    • 2014-04-18
    • 1970-01-01
    • 2014-01-15
    • 2013-12-30
    • 1970-01-01
    • 2013-09-23
    • 2013-04-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多