locked
[UWP] On a 4 inch screen the ComboBox sometimes is empty RRS feed

  • Question

  • I managed to reproduce this problem on a phone with a 4 inch screen. It did not happen when using the >= 5.0 inch emulators.


    On my app, the ComboBox loads fine only and only if I do not input any text in the textbox immediately above it. The moment I put the cursor into the textbox, type any text, and then click at the ComboBox, all of the items that were on it are gone.

    <Page
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="using:ContasSimplesPro.Pages"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        x:Class="ContasSimplesPro.Pages.LancamentoPage"
        mc:Ignorable="d"
        RequestedTheme="Light">
    
        <Page.Transitions>
            <TransitionCollection>
                <NavigationThemeTransition>
                    <NavigationThemeTransition.DefaultNavigationTransitionInfo>
                        <ContinuumNavigationTransitionInfo/>
                    </NavigationThemeTransition.DefaultNavigationTransitionInfo>
                </NavigationThemeTransition>
            </TransitionCollection>
        </Page.Transitions>
    
        <Grid Background="#EEEEEE">
            <ScrollViewer VerticalScrollMode="Auto" VerticalScrollBarVisibility="Hidden" Margin="0,10,0,0" >
                <Grid Height="630" >
                    <TextBox x:Name="txtDescricao" Header="Descrição *" Margin="10,10,10,0" TextWrapping="NoWrap" MaxLength="60" Height="60" VerticalAlignment="Top" />
                    <ComboBox x:Name="ListaTipoDespesa" 
            	ItemsSource="{Binding}" 
            	Header="Tipo Despesa *"  
            	Margin="10,75,10,0" 
            	BorderThickness="2" 
            	VerticalAlignment="Top" 
            	HorizontalAlignment="Stretch" Height="65" >
                        <ComboBox.ItemTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding Descricao}"/>
                            </DataTemplate>
                        </ComboBox.ItemTemplate>
                    </ComboBox>
    
                    <ComboBox x:Name="ListaFormaPagamento" 
    					ItemsSource="{Binding}" 
    					Header="Forma de Pagamento *"
    					Margin="10,145,10,0" 
    					SelectionChanged="ListaFromarPagamento_OnSelectionChanged" 
    					BorderThickness="2" VerticalAlignment="Top" HorizontalAlignment="Stretch" Height="65" >
                        <ComboBox.ItemTemplate>
                            <DataTemplate>
                                <StackPanel>
                                    <TextBlock Text="{Binding Descricao}" />
                                </StackPanel>
                            </DataTemplate>
                        </ComboBox.ItemTemplate>
                    </ComboBox>
    
                    <DatePicker Header="Vencimento *" x:Name="Vencimento" Margin="10,215,10,0" VerticalAlignment="Top" HorizontalAlignment="Stretch" Height="64" />
                    <TextBox x:Name="txtParcelas" Header="Nº Parcelas" TextAlignment="Center" Margin="10,280,0,0" TextWrapping="NoWrap" MaxLength="2" InputScope="Number" KeyUp="txtParcelas_KeyUp" KeyDown="txtParcelas_KeyDown" GotFocus="txtParcelas_GotFocus" HorizontalAlignment="Left" Width="130" Height="60" VerticalAlignment="Top"/>
                    <ToggleSwitch x:Name="boolParcela" Header="Valor Parcela" OnContent="Sim" OffContent="Não" HorizontalAlignment="Right" Margin="0,280,10,0" VerticalAlignment="Top" Toggled="boolParcela_Toggled" Width="29" Height="60" />
                    <TextBox x:Name="txtValorTotal" Header="Valor Total *" Margin="10,345,0,0" MaxLength="10" TextWrapping="Wrap" InputScope="Number" KeyUp="txtValorTotal_KeyUp" KeyDown="txtValorTotal_KeyDown" GotFocus="txtValorTotal_GotFocus" HorizontalAlignment="Left" Width="138" Height="60" VerticalAlignment="Top"/>
                    <TextBox x:Name="txtValorParcela" Header="Valor Parcela *" IsEnabled="False" Margin="0,345,10,0" TextWrapping="Wrap" MaxLength="10" InputScope="Number" KeyUp="txtValorParcela_KeyUp" KeyDown="txtValorParcela_KeyDown" GotFocus="txtValorParcela_GotFocus" HorizontalAlignment="Right" Width="154" Height="60" VerticalAlignment="Top"/>
                    <ToggleSwitch x:Name="boolParcelaPaga" Header="Já paguei?" OnContent="Sim" OffContent="Não" HorizontalAlignment="Left" Margin="10,410,0,0" VerticalAlignment="Top" Width="154" Toggled="boolParcelaPaga_Toggled" Height="60"/>
                </Grid>
            </ScrollViewer>
        </Grid>
    
    </Page>



    • Edited by CodeSanches Tuesday, January 26, 2016 2:31 PM
    Tuesday, January 26, 2016 12:34 PM

Answers

  • I researched a bit and managed to solve . ComboBox has the standard item as Carousel and I was going stackpanel . What I did was just change the Carousel of ItensPanel by Stackepanel .

    Caution  ComboBox uses a CarouselPanel as its ItemsPanel. Using a different panel as the ItemsPanel is not supported and might result in undesired behavior.

                        <ComboBox.ItemsPanel>
                            <ItemsPanelTemplate>
                                <StackPanel HorizontalAlignment="Stretch"/>
                            </ItemsPanelTemplate>
                        </ComboBox.ItemsPanel>
    
                        <ComboBox.ItemTemplate>
                            <DataTemplate>
                                <StackPanel>
                                    <TextBlock Text="{Binding Descricao}"/>
                                </StackPanel>
                            </DataTemplate>
                        </ComboBox.ItemTemplate>

    • Marked as answer by CodeSanches Wednesday, January 27, 2016 9:00 PM
    Wednesday, January 27, 2016 11:55 AM
  • Greateful for the attention. xD
    Grateful for the attention.
    • Marked as answer by CodeSanches Wednesday, January 27, 2016 9:00 PM
    Wednesday, January 27, 2016 11:56 AM

All replies

  • Welcome CodeSanches!

    Have to go with a bug in the emulator, if it works on 5 inch, and doesn't on 4 inch, then I would think that you have found a bug.

    I checked it myself and it didn't occur on my system (hopefully I set up the test correctly).  However, I am running Visual Studio 2015 Update 1 on Windows 10 version 10586.

    Like you did most likely I did a bing search (because I get points!) and came up with nothing about this.

    So maybe check your version of Visual Studio and Windows.  Which would be an easy fix right?

    Let me know if this helped out by marking this as answered, or leave a note telling me it didn't work. 


    Sam Stokes

    Wednesday, January 27, 2016 4:12 AM
  • I've seen this too. If memory serves it was a problem with the carousel control it uses, I'll try and find the workaround. 

    http://pauliom.wordpress.com

    Wednesday, January 27, 2016 6:52 AM
  • can show some more code?

    Microsoft Certified Solutions Developer - Windows Store Apps Using C#

    Wednesday, January 27, 2016 7:44 AM
  • <ComboBox.ItemsPanel>
                            <ItemsPanelTemplate>
                                <VirtualizingStackPanel MaxWidth="{Binding ElementName=NameOfComboBox, Path=ActualWidth}"/>
                            </ItemsPanelTemplate>
                        </ComboBox.ItemsPanel>

    This was the workaround for our issue, might be the same problem you're seeing


    http://pauliom.wordpress.com

    Wednesday, January 27, 2016 9:43 AM
  • I researched a bit and managed to solve . ComboBox has the standard item as Carousel and I was going stackpanel . What I did was just change the Carousel of ItensPanel by Stackepanel .

    Caution  ComboBox uses a CarouselPanel as its ItemsPanel. Using a different panel as the ItemsPanel is not supported and might result in undesired behavior.

                        <ComboBox.ItemsPanel>
                            <ItemsPanelTemplate>
                                <StackPanel HorizontalAlignment="Stretch"/>
                            </ItemsPanelTemplate>
                        </ComboBox.ItemsPanel>
    
                        <ComboBox.ItemTemplate>
                            <DataTemplate>
                                <StackPanel>
                                    <TextBlock Text="{Binding Descricao}"/>
                                </StackPanel>
                            </DataTemplate>
                        </ComboBox.ItemTemplate>

    • Marked as answer by CodeSanches Wednesday, January 27, 2016 9:00 PM
    Wednesday, January 27, 2016 11:55 AM
  • Greateful for the attention. xD
    Grateful for the attention.
    • Marked as answer by CodeSanches Wednesday, January 27, 2016 9:00 PM
    Wednesday, January 27, 2016 11:56 AM