简体   繁体   中英

I can't get the listView to show up when running the app

I'm designing a really stupid app, but I need a listview to show me a list of different inputs. When I'm in the.xaml file designer, I can see the listview plain and clear, and added a listviewitem in it, but when I run the app, the listview doesn't show up.

I've tried changing the system theme on my pc, using the build tools tools when running to look at the "hitboxes" of my elements, and changed the border and background brush colors. Idk what else to do, or change.

this is the.xaml file for my app, without all the other elements -

    <ListView x:Name="lstListView" Margin="321,50,985,633" CanDragItems="True" RequestedTheme="Default" BorderThickness="1,1,1,1">
        <ListView.BorderBrush>
            <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                <GradientStop Color="Black"/>
                <GradientStop Color="White" Offset="1"/>
            </LinearGradientBrush>
        </ListView.BorderBrush>
        <ListViewItem Content="ListViewItem"/>
    </ListView>

I used your code to make a simple test. The issue is caused by the margin of the listview, the value for margin-right(985) is too big. You need to maximize the window of your app to see the listview. Another way is that you could change is into a smaller one.

Please refer to this document for more information about margin: Margin and padding .

picture of it working in windowed mode

picture of the VS IDE I'm using

Since I'm using Visual Studio as the IDE, I can edit the.xaml layout through a handy little GUI. When I click the listView element, there are lines running perpendicular from the middle of each side connecting to the border of the window(the GUI 'emulated' window layout I'm creating) that display the margin amount. On the intersection of the line and the border, there is a little chain link icon, and clicking that will 'unlink' the margin, and allow it to conform to whatever window size, and adjust to all the other margins. All I needed to do was 'unlink' the bottom and right margins, and it was working the way I wanted.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM