Observable Collections
page 9 of 9
by frans eilering
Feedback
Average Rating: 
Views (Total / Last 10 Days): 43996/ 71

Hide the ID column

To hide the IDContact column insert a second datagrid.

<UserControl x:Class="ObservableCollection.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="732" 
xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk">
 
    <Grid x:Name="LayoutRoot" Background="White">
        <sdk:DataGrid x:Name="Datagrid2" AutoGenerateColumns="False">
            <sdk:DataGrid.Columns>
                <sdk:DataGridTextColumn Header="Name" 
                Binding="{Binding Name}" />
                <sdk:DataGridTextColumn Header="Address" 
                Binding="{Binding Address}" />
                <sdk:DataGridTextColumn Header="City" 
                Binding="{Binding City}" />
                <sdk:DataGridTextColumn Header="IDContact" 
                Binding="{Binding IDContact}"  Visibility="Collapsed"/>
            </sdk:DataGrid.Columns>
        </sdk:DataGrid>
        <sdk:DataGrid 
            AutoGenerateColumns="True" 
            Height="121" 
            HorizontalAlignment="Left" 
            Margin="9,167,0,0" 
            Name="DataGrid1" 
            VerticalAlignment="Top" 
            Width="711" />
    </Grid>
</UserControl>
And set Visibility="Collapsed" for this column.
It the Mainpage.aspx.vb code insert the next code

Code for extra datagrid

  Sub GetContactcompleted(ByVal sender As Object, ByVal e As 
ServiceReference1.FindContactListCompletedEventArgs)
        MyList = e.Result
 
        MyList.Add(New ServiceReference1.Contact() With { _
        .IDContact = 101, _
        .Name = "new", _
        .Address = "", _
        .City = "" _
       })
 
        Dim TopData = From NewData In MyList
              Order By NewData.Name Descending
              Take (2)
        DataGrid1.ItemsSource = TopData
        Datagrid2.ItemsSource = MyList
 
    End Sub

Download sample project.


View Entire Article

User Comments

Title: C# Code example   
Name: eilering
Date: 2011-09-16 3:50:25 AM
Comment:
The VB code is very basic. If you copy the code and use a convertor like
http://converter.telerik.com/
then you can paste it and you get the C# code.

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2021 ASPAlliance.com  |  Page Processed at 2021-11-29 6:22:15 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search