RSS

Tag Archives: ListBox

Show a List as ReadOnly

I have often the situation when I need showing a list and I do use a ListBox I do not need that the selected item is highlighted. If I use a ListBox for displaying a list of data then this looks like:

image

But as you can see there is a highlighted item which we want to avoid. How can we avoid that? This is achieved by using an ItemsControl. Then we have solved the problem and the list looks like:

image

 
Leave a comment

Posted by on May 9, 2012 in C-Sharp, WPF

 

Tags: ,

WP7 ListBox does not scroll

If you have the problem that your ListBox, created in XAML, does not have the ability to scoll (even though you have put it into scope of a ScollViewer) you may have the case that you put your ListBox into a StackPanel. There it would not scroll.

You may have following 2 cases:

<StackPanel>
    <Label Content="MyList"/>
    <ListBox ItemsSource="{Binding MySuperDuperList}"/>
</StackPanel>
<StackPanel>
    <Label Content="MyList"/>
    <ScrollViewer>
        <ListBox ItemsSource="{Binding MySuperDuperList}"/>
    </ScrollViewer>
</StackPanel>

To solve the problem put the ListBox into scope of a Grid, then it will scoll again.

<StackPanel>
    <Label Content="MyList"/>
    <Grid>
        <ListBox ItemsSource="{Binding MySuperDuperList}"/>
    </Grid>
</StackPanel>
 
1 Comment

Posted by on May 22, 2011 in WP7

 

Tags: , ,