Strange behavior in ListView RRS feed

  • Question

  • Hi experts. 

    I have a listview that is a strange compartamento he preeche dynamically a value field. While the textblock is "visible" in the listview the value is filled in correctly. When the field is not visible (needing scroll bar) I got the error: Input string was not in a correct format. 

    Has anyone had a similar experience?

    <ListView x:Name="grdContasDia" ItemsSource="{Binding}"  
                  MinWidth="500" MinHeight="675"
                  HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"
                  Foreground="#FF307FB6" BorderThickness="2" BorderBrush="#FF307FB6" CanDragItems="True" CanReorderItems="True" ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Hidden" >
                    <DataTemplate >
                        <StackPanel Orientation="Vertical" Margin="50,0" Name="spPrincpal" Width="1200">
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="Código - " FontSize="36" FontFamily="Arial Black" />
                                <TextBlock Name="txbId" Text="{Binding Id}" FontSize="36" FontFamily="Arial Black" Margin="10,0" />
                                <TextBlock Text="Tipo - " FontSize="36" FontFamily="Arial Black" />
                                <TextBlock Name="txbConta" Text="{Binding DescDespesa}" FontSize="36" FontFamily="Arial Black" Margin="10,0"/>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock  Text="Valor "  FontSize="24" FontFamily="Arial Black" />
                                <TextBlock Name="txbValor" Text="{Binding Valor}"  FontSize="24" FontFamily="Arial Black" Margin="10,0" DataContextChanged="txbValor_DataContextChanged"/>
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="Status: " FontSize="24" FontFamily="Arial Black"/>
                                <TextBlock Name="txbStatus" Text="{Binding Status}"  FontSize="24"  FontFamily="Arial Black" Margin="10,0"/>
                            <Line Stroke="#FF307FB6" X1="0" Y1="25" X2="{Binding ElementName=spPrincpal, Path=Width}" Y2="25" />

            private async void Page_Loaded(object sender, RoutedEventArgs e)
                //Seta o tamanho máximo do Listview
                this.grdContasDia.MaxHeight = this.ActualHeight - 200;
                //Preenche ListView
                await FillPage(dt);
            private async Task<bool> FillPage(DateTime date)
                bool bRetorno = false;
                    ControllerContas cc = new ControllerContas();
                    List<Contas> lstContas = new List<Contas>();
                    lstContas = cc.ListarContas(date);
                    if (lstContas.Count > 0)
                        this.grdContasDia.ItemsSource = lstContas.ToList();
                        txbDia.Text = date.ToString("dd/MM/yyyy");
                        var valor = (from o in lstContas
                                     select o.Valor).Sum();
                        txbValorTotal.Text = valor.ToString("C");
                        MessageDialog msg = new MessageDialog("Não existem contas lançadas para este dia!", "Aviso");
                        await msg.ShowAsync();
                catch (Exception)
                return bRetorno;

    Brian Souza - MCP Desenvolvedor C#.Net

    Tuesday, April 22, 2014 7:39 PM

All replies

  • I can't run this code because it has references to objects that aren't in the code you've shown. Can you post a link to a working project?

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Wednesday, April 23, 2014 12:33 PM