Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ListView height inside of a StackPanel - problem...
Message
From
20/06/2008 09:37:14
 
 
To
19/06/2008 21:33:17
General information
Forum:
ASP.NET
Category:
Windows Presentation Foundation (WPF)
Miscellaneous
Thread ID:
01325263
Message ID:
01325713
Views:
14
FYI - for those interested - I also have added incremental lookup feature here by using the KeyUp method on the TextBox to update the Linq Query and filter based on CustID or CompanyName containing the incrementally typed text. Our CustID's are character based, and some users look up by ID, but some look up by comany name, so this serves both ways.

P.S. - Excuse the horrible colors... I'm just using some weird colors to see the effect of it on the rendering. I'm beginning to see the need (or place) for "Designers" (i.e. graphical UI minded types) vs. "Developers", a topic I've heard a lot about with respect to WPF.


Maybe theres a better hook that KeyUp, but it seems to work.


Also, this pincremental requery performs well, but I am only querying about 300 records. Not sure this would perform well on a very large data set.



Here is my final xaml:
<Window x:Class="wpf2.Window1"  
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"  
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"  
    Title="Window1" Height="600" Width="300">   
    <Grid>  
        <Grid.RowDefinitions>  
            <RowDefinition Height="Auto"></RowDefinition>  
            <RowDefinition Height="*"></RowDefinition>  
        </Grid.RowDefinitions>  
        <StackPanel Orientation="Horizontal" Grid.Row="0">   
            <TextBox x:Name="txtCustomerFilter" CharacterCasing="Upper" Width="100" Margin="5" KeyUp="ButtonSearch_Click"></TextBox>  
            <Button x:Name="ButtonSearch" Width="50" Margin="5" Click="ButtonSearch_Click">Search</Button>  
        </StackPanel>  
        <ListView Name="lv2" HorizontalContentAlignment="Stretch" ScrollViewer.VerticalScrollBarVisibility="Visible" Grid.Row="1" Background="DarkBlue">   
            <ListView.ItemTemplate>  
                <DataTemplate>  
                    <Border Margin="5" BorderThickness="1" BorderBrush="SlateGray" CornerRadius="4" Background="CadetBlue">   
                        <Grid Margin="3">   
                            <Grid.RowDefinitions>  
                                <RowDefinition></RowDefinition>   
                                <RowDefinition></RowDefinition>   
                                <RowDefinition></RowDefinition>   
                                <RowDefinition></RowDefinition>   
                            </Grid.RowDefinitions>  
                            <Grid.ColumnDefinitions>  
                                <ColumnDefinition></ColumnDefinition>   
                            </Grid.ColumnDefinitions>  
                            <StackPanel Orientation="Horizontal">   
                             <TextBlock FontWeight="Bold" Text="{Binding Path=custno}"></TextBlock>  
                             <TextBlock Text="{Binding Path=company}" Margin="5,0,0,0"></TextBlock>  
                            </StackPanel>  
                            <StackPanel Grid.Row="1" Orientation="Horizontal">   
                             <TextBlock>Phone:</TextBlock>  
                             <TextBlock Text="{Binding Path=phone}" Margin="5,0,0,0"></TextBlock>  
                            </StackPanel>  
                            <StackPanel Grid.Row="2" Orientation="Horizontal">   
                             <TextBlock>Fax:</TextBlock>  
                             <TextBlock Text="{Binding Path=faxno}" Margin="5,0,0,0"></TextBlock>  
                            </StackPanel>  
                        </Grid>  
                    </Border>  
                </DataTemplate>  
            </ListView.ItemTemplate>  
        </ListView>  
</Grid>  
  
</Window>  



and the code-behine:
        public void ButtonSearch_Click(object sender, RoutedEventArgs e)   
        {   
            DataClasses1DataContext db = new DataClasses1DataContext();   
  
            var CustomerFilter='%'+txtCustomerFilter.Text+'%';   
  
            var customers = from a in db.customers   
                            where SqlMethods.Like(a.custno,CustomerFilter) || SqlMethods.Like(a.company,CustomerFilter)    
                            orderby a.custno   
                            select new { a.custno, a.company, a.phone, a.faxno };   
  
            lv2.ItemsSource = customers;   
  
              
        }  
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform