Click here to Skip to main content
15,881,757 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
HTML
<Window x:Class="WpfA12112.MainWindow"
               xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:dg="http://schemas.microsoft.com/wpf/2008/toolkit"
        Title="   HI HOME" Height="859" Width="1300" WindowState="Maximized" 
        WindowStyle="ThreeDBorderWindow" BorderBrush="Red" 
        Foreground="DarkViolet" FontSize="20" FontWeight="Bold" 
        AllowDrop="True"  Name="myWindow" Loaded="myWindow_Loaded"
        HorizontalContentAlignment="Left" ResizeMode="CanResizeWithGrip" 
        Topmost="True" HorizontalAlignment="Left" VerticalAlignment="Top"
        FlowDirection="LeftToRight"
        xmlns:my="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit" 

        xmlns:localprimitives="clr-namespace:Microsoft.Windows.Controls.Primitives;assembly=WPFToolkit">
        


    <Window.Resources>
        <!-- DataGrid style -->
        <Style x:Key="DataGridStyle1" TargetType="{x:Type DataGrid}">
            <Setter Property="ColumnHeaderStyle" Value="{DynamicResource
                ColumnHeaderStyle1}"/>
        </Style>
        <!-- DataGridColumnHeader style -->
        <Style x:Key="ColumnHeaderStyle1" TargetType="DataGridColumnHeader">
            <Setter Property="Height" Value="30"/>
            <Setter Property="Background" Value="LightBlue"/>
            <Setter Property="Foreground" Value="Blue"/>
            <Setter Property="FontSize" Value="18" />

            <Style.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter Property="ToolTip" Value="Click to sort"/>
                </Trigger>
            </Style.Triggers>
        </Style>
        
      
       
    </Window.Resources>
    <Grid >
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="15*" />
            <ColumnDefinition Width="20*" />
            <ColumnDefinition Width="20*" />
            <ColumnDefinition Width="22*" />
            <ColumnDefinition Width="18*" />
            <ColumnDefinition Width="20*" />
            <ColumnDefinition Width="35*" />
            <ColumnDefinition Width="22*" />
            <ColumnDefinition Width="18*" />
            <ColumnDefinition Width="15*" />
            <ColumnDefinition Width="25*" />
            <ColumnDefinition Width="22*" />
            <ColumnDefinition Width="20*" />
            <ColumnDefinition Width="18*" />
            <ColumnDefinition Width="12*" />
            <ColumnDefinition Width="12*" />
            <ColumnDefinition Width="18*" />
            <ColumnDefinition Width="12*" />
            <ColumnDefinition Width="30*" />
            <ColumnDefinition Width="18*" />
            <ColumnDefinition Width="15*" />
            <ColumnDefinition Width="28*" />
            <ColumnDefinition Width="35*" />
            <ColumnDefinition Width="28*" />
            <ColumnDefinition Width="22*" />
            <ColumnDefinition Width="28*" />
            <ColumnDefinition Width="18*" />
            <ColumnDefinition Width="22*" />
            <ColumnDefinition Width="22*" />
            <ColumnDefinition Width="12*" />
            <ColumnDefinition Width="15*" />
            <ColumnDefinition Width="15*" />
            <ColumnDefinition Width="12*" />
            <ColumnDefinition Width="13*" />
            <ColumnDefinition Width="10*" />
            <ColumnDefinition Width="12*" />
            <ColumnDefinition Width="22*" />
            <ColumnDefinition Width="12*" />
            <ColumnDefinition Width="20*" />
            <ColumnDefinition Width="15*" />
            <ColumnDefinition Width="18*" />
            <ColumnDefinition Width="12*" />
            <ColumnDefinition Width="22*" />
            <ColumnDefinition Width="18*" />
            <ColumnDefinition Width="18*" />
            <ColumnDefinition Width="15*" />
            <ColumnDefinition Width="28*" />
            <ColumnDefinition Width="18*" />
            <ColumnDefinition Width="18*" />
            <ColumnDefinition Width="12*" />
            <ColumnDefinition Width="25*" />
            <ColumnDefinition Width="15*" />
            <ColumnDefinition Width="38*" />
            <ColumnDefinition Width="35*" />
            <ColumnDefinition Width="28*" />
            <ColumnDefinition Width="22*" />
            <ColumnDefinition Width="30*" />
            <ColumnDefinition Width="12*" />
            <ColumnDefinition Width="20*" />
            <ColumnDefinition Width="8*" />
            <ColumnDefinition Width="9*" />
            <ColumnDefinition Width="8*" />
            <ColumnDefinition Width="12*" />
            <ColumnDefinition Width="25*" />
            <ColumnDefinition Width="25*" />
            <ColumnDefinition Width="19*" />
        </Grid.ColumnDefinitions>

        <Grid.RowDefinitions>
            <RowDefinition Height="25*" />
            <RowDefinition Height="35*" />
            <RowDefinition Height="28*" />
            <RowDefinition Height="22*" />
            <RowDefinition Height="35*" />
            <RowDefinition Height="20*" />
            <RowDefinition Height="25*" />
            <RowDefinition Height="28*" />
            <RowDefinition Height="30*" />
            <RowDefinition Height="25*" />
            <RowDefinition Height="32*" />
            <RowDefinition Height="25*" />
            <RowDefinition Height="22*" />
            <RowDefinition Height="25*" />
            <RowDefinition Height="25*" />
            <RowDefinition Height="15*" />
            <RowDefinition Height="22*" />
            <RowDefinition Height="20*" />
            <RowDefinition Height="22*" />
            <RowDefinition Height="22*" />
            <RowDefinition Height="15*" />
            <RowDefinition Height="18*" />
            <RowDefinition Height="22*" />
            <RowDefinition Height="20*" />
            <RowDefinition Height="20*" />
            <RowDefinition Height="15*" />
            <RowDefinition Height="18*" />
            <RowDefinition Height="15*" />
            <RowDefinition Height="15*" />
            <RowDefinition Height="25*" />
            <RowDefinition Height="30*" />
            <RowDefinition Height="20*" />
            <RowDefinition Height="20*" />
            <RowDefinition Height="18*" />
            <RowDefinition Height="12*" />
            <RowDefinition Height="18*" />
            <RowDefinition Height="20*" />
            <RowDefinition Height="12*" />
            <RowDefinition Height="25*" />
        </Grid.RowDefinitions>
        <Grid.Background>
            <ImageBrush ImageSource="/WpfA12112;component/Images/Tulips.jpg" />
        </Grid.Background>
        <Menu Height="30" Name="menu1" VerticalAlignment="Top" BorderThickness="2"
              Foreground="White" FontSize="16" FontWeight="Bold" Margin="-2,-2,0,0" 
              Grid.RowSpan="2" Grid.ColumnSpan="66">
            <Menu.Background>
                <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
                    <GradientStop Color="#FF3A60AD" Offset="0.528"/>
                    <GradientStop Color="#FF6A85D8" Offset="0.01"/>
                    <GradientStop Color="#FF3464C4" Offset="1"/>
                    <GradientStop Color="#FF202E7E" Offset="1"/>
                </LinearGradientBrush>
            </Menu.Background>
            <Menu.BitmapEffect>
                <DropShadowBitmapEffect />
            </Menu.BitmapEffect>
            <MenuItem Header="File" Click="MenuItem_Click">
                <MenuItem Header="Teachers" Foreground="Black" >
                    <MenuItem.Background>
                        <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
                            <GradientStop Color="SteelBlue" Offset="0.528"/>
                            <GradientStop Color="Blue" Offset="0.01"/>
                            <GradientStop Color="Cyan" Offset="1"/>
                            <GradientStop Color="Orange" Offset="1"/>
                        </LinearGradientBrush>

                    </MenuItem.Background>

                    <MenuItem.ToolTip>
                        <ToolTip>
                            Open a file.
                        </ToolTip>
                    </MenuItem.ToolTip>
                </MenuItem>
                <MenuItem Header="_Close" >
                    <MenuItem.Background>
                        <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
                            <GradientStop Color="SteelBlue" Offset="0.528"/>
                            <GradientStop Color="Blue" Offset="0.01"/>
                            <GradientStop Color="Cyan" Offset="1"/>
                            <GradientStop Color="Orange" Offset="1"/>
                        </LinearGradientBrush>

                    </MenuItem.Background>
                </MenuItem>
                <MenuItem Header="_Save" Foreground="Black">
                    <MenuItem.Background>
                        <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
                            <GradientStop Color="Yellow" Offset="0.528"/>
                            <GradientStop Color="YellowGreen" Offset="0.01"/>
                            <GradientStop Color="Bisque" Offset="1"/>
                            <GradientStop Color="Orange" Offset="1"/>
                        </LinearGradientBrush>

                    </MenuItem.Background>
                </MenuItem>
                <Separator/>
                <MenuItem Header="Sub Items">
                    <MenuItem Header="Child1 SubItem" />
                    <MenuItem Header="Child2 SubItem">
                        <MenuItem Header="GrandChild2 SubItem" />
                    </MenuItem>
                </MenuItem>

            </MenuItem>
            <MenuItem Header="Departments" Foreground="Orange" FontSize="16" >

            </MenuItem>
            <MenuItem Header="Subjects" Foreground="White" FontSize="16">

            </MenuItem>
            <MenuItem Header="Cources"  Foreground="LightGreen" FontSize="16">


            </MenuItem>
        </Menu>


        <Border BorderBrush="Blue" BorderThickness="0" HorizontalAlignment="Stretch" Name="border1"
                VerticalAlignment="Stretch" CornerRadius="0" Opacity="100" UseLayoutRounding="True" Margin="0,1,0,-2" Grid.Row="1" Grid.RowSpan="38" Grid.ColumnSpan="66"></Border>
        <StackPanel HorizontalAlignment="Right" Margin="0,24,0,0" Name="stackPanel1" VerticalAlignment="Top" CanHorizontallyScroll="True" Grid.RowSpan="6" Grid.Column="61" Grid.ColumnSpan="5" Width="89">
            <Button Content="Open" Height="Auto" Name="btnOpen" Background="LimeGreen" Click="btnOpen_Click" Width="90" HorizontalAlignment="Right" />
            <Button Content="Update" Name="btnUpdate" Background="Orange" Click="btnUpdate_Click" Height="Auto" Width="89" HorizontalAlignment="Right" />
            <Button Content="Button" Name="btnwindow1" Width="89" Background="#FFB23434" Click="btnwindow1_Click" Height="34" />
            <Button Content="Excel" Name="btnExcel" IsDefault="False" Background="CornflowerBlue" Click="btnExcel_Click" Height="Auto" Width="90" HorizontalAlignment="Right" />
        </StackPanel>
        <dg:DataGrid Name="dataGrid1" Width="1189" HorizontalAlignment="Left" VerticalContentAlignment="Stretch" Loaded="dataGrid1_Loaded" EnableColumnVirtualization="False"
                     HorizontalScrollBarVisibility="Auto" IsManipulationEnabled="True" ForceCursor="False" FrozenColumnCount="1" IsHitTestVisible="True" BorderThickness="2" 
                     FontSize="20" FontFamily="Century Gothic" FontWeight="Normal" AlternationCount="1" 
                     RowHeaderWidth="15" RowHeight="40" SelectionMode="Single" SelectionUnit="CellOrRowHeader" AlternatingRowBackground="Black" RowBackground="Black" 
                     removed="Black" CanUserReorderColumns="True" CanUserResizeColumns="True" CanUserSortColumns="True" BorderBrush="#FFD51E1E" Foreground="White"
                     EnableRowVirtualization="False" DataContext="{Binding}" DisplayMemberPath="{Binding}" ItemsSource="{Binding}" IsSynchronizedWithCurrentItem="True"
                     SelectedValuePath="{Binding}" AutoGenerateColumns="False" GridLinesVisibility="All" AreRowDetailsFrozen="True" HorizontalGridLinesBrush="Snow"
                     VerticalGridLinesBrush="Snow" Margin="0,0,0,-4" Grid.Row="1" Grid.RowSpan="38" Grid.ColumnSpan="61" Height="890">
            <dg:DataGrid.Resources>
                <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Silver" />
            </dg:DataGrid.Resources>
            <dg:DataGrid.RowValidationRules>
                <ExceptionValidationRule ValidatesOnTargetUpdated="True" ValidationStep="UpdatedValue" />
                <ExceptionValidationRule ValidatesOnTargetUpdated="True" ValidationStep="CommittedValue" />
            </dg:DataGrid.RowValidationRules>
            <dg:DataGrid.Columns>
                <dg:DataGridTextColumn Header="AuthorID" FontWeight="Black" Foreground="Red"
                                       FontSize="16" FontStyle="Italic" 
                                       CanUserReorder="True" Binding="{Binding Path= AuthorID}" 
                                       CanUserSort="True" SortDirection="Ascending">
                    <dg:DataGridTextColumn.ElementStyle>
                        <Style TargetType="TextBlock">
                            <Setter Property="TextAlignment" Value="Center" />
                        </Style>
                    </dg:DataGridTextColumn.ElementStyle>
                    <dg:DataGridTextColumn.EditingElementStyle>
                        <Style TargetType="TextBox">
                            <Setter Property="TextWrapping" Value="Wrap" />
                            <Setter Property="AcceptsReturn" Value="true" />
                        </Style>
                    </dg:DataGridTextColumn.EditingElementStyle>
                    <dg:DataGridColumn.HeaderStyle>
                        <Style TargetType="{x:Type dg:DataGridColumnHeader}">
                            <Setter Property="Background" >
                                <Setter.Value>
                                    <LinearGradientBrush EndPoint="1,1" StartPoint="0.5,0" SpreadMethod="Pad">
                                        <GradientStop Color="Bisque" Offset="0" />
                                        <GradientStop Color="Cyan" Offset="1" />
                                    </LinearGradientBrush>
                                </Setter.Value>
                            </Setter>
                            <Setter Property="Foreground" Value="Black" />
                            <Setter Property="FontSize" Value="20" />
                            <Setter Property="HorizontalContentAlignment" Value="Center" />
                            <Setter Property="BorderBrush" Value="yellow"/>
                            <Setter Property="BorderThickness" Value="2,2,2,2"/>
                        </Style>
                    </dg:DataGridColumn.HeaderStyle>
                </dg:DataGridTextColumn>
                <dg:DataGridTextColumn Header="FirstName" FontWeight="Bold" Foreground="DarkGreen" FontSize="16" FontStyle="Italic" 
                                       CanUserSort="False" Binding="{Binding Path=FirstName}">
                    <dg:DataGridTextColumn.ElementStyle>
                        <Style TargetType="TextBlock">
                            <Setter Property="TextAlignment" Value="Center" />
                        </Style>
                    </dg:DataGridTextColumn.ElementStyle>
                    <dg:DataGridTextColumn.EditingElementStyle>
                        <Style TargetType="TextBox">
                            <Setter Property="TextWrapping" Value="Wrap" />
                            <Setter Property="AcceptsReturn" Value="true" />
                        </Style>
                    </dg:DataGridTextColumn.EditingElementStyle>
                    <dg:DataGridColumn.HeaderStyle>
                        <Style TargetType="{x:Type dg:DataGridColumnHeader}">

                            <Setter Property="Background" >
                                <Setter.Value>
                                    <LinearGradientBrush EndPoint="1,1" StartPoint="0.5,0" SpreadMethod="Pad">
                                        <GradientStop Color="Lavender" Offset="0" />
                                        <GradientStop Color="BlanchedAlmond" Offset="1" />
                                    </LinearGradientBrush>
                                </Setter.Value>
                            </Setter>
                            <Setter Property="Foreground" Value="Black" />
                            <Setter Property="FontSize" Value="20" />
                            <Setter Property="HorizontalContentAlignment" Value="Center" />
                            <Setter Property="Width" Value="Auto" />
                            <Setter Property="BorderBrush" Value="Yellow"/>
                            <Setter Property="BorderThickness" Value="2,2,2,2"/>
                        </Style>
                    </dg:DataGridColumn.HeaderStyle>
                </dg:DataGridTextColumn>
                <dg:DataGridTextColumn Header="LastName" FontWeight="Bold" Foreground="OrangeRed" FontSize="16" FontStyle="Italic" 
                                       CanUserSort="False" Binding="{Binding Path=LastName}">
                    <dg:DataGridTextColumn.ElementStyle>
                        <Style TargetType="TextBlock">
                            <Setter Property="TextAlignment" Value="Center" />
                        </Style>
                    </dg:DataGridTextColumn.ElementStyle>
                    <dg:DataGridTextColumn.EditingElementStyle>
                        <Style TargetType="TextBox">
                            <Setter Property="TextWrapping" Value="Wrap" />
                            <Setter Property="AcceptsReturn" Value="true" />
                        </Style>
                    </dg:DataGridTextColumn.EditingElementStyle>
                    <dg:DataGridColumn.HeaderStyle>
                        <Style TargetType="{x:Type dg:DataGridColumnHeader}">
                            <Setter Property="Background" >
                                <Setter.Value>
                                    <LinearGradientBrush EndPoint="1,1" StartPoint="0.5,0" SpreadMethod="Pad">
                                        <GradientStop Color="Brown" Offset="0" />
                                        <GradientStop Color="White" Offset="1" />
                                    </LinearGradientBrush>
                                </Setter.Value>
                            </Setter>
                            <Setter Property="Foreground" Value="Black" />
                            <Setter Property="FontSize" Value="20" />
                            <Setter Property="HorizontalContentAlignment" Value="Center" />
                            <Setter Property="Width" Value="Auto" />
                            <Setter Property="BorderBrush" Value="Yellow"/>
                            <Setter Property="BorderThickness" Value="2,2,2,2"/>
                        </Style>
                    </dg:DataGridColumn.HeaderStyle>
                </dg:DataGridTextColumn>
                <dg:DataGridTemplateColumn Header="DOB" MinWidth="100" CanUserSort="False">
                    <dg:DataGridTemplateColumn.HeaderStyle>
                        <Style TargetType="{x:Type dg:DataGridColumnHeader}">
                            <Setter Property="Background" >
                                <Setter.Value>
                                    <LinearGradientBrush EndPoint="1,.1" StartPoint="0.5,1" SpreadMethod="Pad">
                                        <GradientStop Color="Orange" Offset="1" />
                                        <GradientStop Color="Thistle" Offset="0" />
                                    </LinearGradientBrush>
                                </Setter.Value>
                            </Setter>
                            <Setter Property="Foreground" Value="Black" />
                            <Setter Property="FontSize" Value="20" />
                            <Setter Property="HorizontalContentAlignment" Value="Center" />
                            <Setter Property="Width" Value="Auto" />
                            <Setter Property="BorderBrush" Value="yellow"/>
                            <Setter Property="BorderThickness" Value="2,2,2,2"/>
                        </Style>
                    </dg:DataGridTemplateColumn.HeaderStyle>
                    <dg:DataGridTemplateColumn.CellEditingTemplate>
                        <DataTemplate>
                            <dg:DatePicker SelectedDate="{Binding DOB}" SelectedDateFormat="Short" CalendarStyle="DynamicResource CalenderControlTemplate" removed="Yellow" />
                        </DataTemplate>
                    </dg:DataGridTemplateColumn.CellEditingTemplate>
                    <dg:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding DOB, StringFormat=d}" Foreground="DarkTurquoise" HorizontalAlignment="Center" />
                        </DataTemplate>
                    </dg:DataGridTemplateColumn.CellTemplate>
                </dg:DataGridTemplateColumn>
                <dg:DataGridCheckBoxColumn Header="Pass/Fail" Binding="{Binding Pass}">
                    <dg:DataGridColumn.HeaderStyle>
                        <Style TargetType="{x:Type dg:DataGridColumnHeader}">
                            <Setter Property="Background" >
                                <Setter.Value>
                                    <LinearGradientBrush EndPoint="1,1" StartPoint="0.5,0" SpreadMethod="Pad">
                                        <GradientStop Color="#FFC2D6F6" Offset="0" />
                                        <GradientStop Color="White" Offset="1" />
                                    </LinearGradientBrush>
                                </Setter.Value>
                            </Setter>
                            <Setter Property="Foreground" Value="Black" />
                            <Setter Property="FontSize" Value="20" />
                            <Setter Property="HorizontalContentAlignment" Value="Center" />
                            <Setter Property="Width" Value="Auto" />
                            <Setter Property="BorderBrush" Value="Yellow"/>
                            <Setter Property="BorderThickness" Value="2,2,2,2"/>
                        </Style>
                    </dg:DataGridColumn.HeaderStyle>
                </dg:DataGridCheckBoxColumn>
                <dg:DataGridTextColumn Header="Nationality" FontWeight="Bold" Foreground="SandyBrown" 
                                       FontSize="16" FontStyle="Italic" CanUserSort="False" 
                                       Binding="{Binding Path= Nationality}" Width="Auto">
                    <dg:DataGridTextColumn.ElementStyle>
                        <Style TargetType="TextBlock">
                            <Setter Property="TextAlignment" Value="Center" />
                        </Style>
                    </dg:DataGridTextColumn.ElementStyle>
                    <dg:DataGridTextColumn.EditingElementStyle>
                        <Style TargetType="TextBox">
                            <Setter Property="TextWrapping" Value="Wrap" />
                            <Setter Property="AcceptsReturn" Value="true" />
                        </Style>
                    </dg:DataGridTextColumn.EditingElementStyle>
                    <dg:DataGridColumn.HeaderStyle>
                        <Style TargetType="{x:Type dg:DataGridColumnHeader}">
                            <Setter Property="Background" >
                                <Setter.Value>
                                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0" SpreadMethod="Pad">
                                        <GradientStop Color="Blue" Offset="0" />
                                        <GradientStop Color="White" Offset="1" />
                                    </LinearGradientBrush>
                                </Setter.Value>
                            </Setter>
                            <Setter Property="Foreground" Value="Black" />
                            <Setter Property="FontSize" Value="20" />
                            <Setter Property="HorizontalContentAlignment" Value="Center" />
                            <Setter Property="Width" Value="Auto" />
                            <Setter Property="BorderBrush" Value="Yellow"/>
                            <Setter Property="BorderThickness" Value="2,2,2,2"/>
                        </Style>
                    </dg:DataGridColumn.HeaderStyle>
                </dg:DataGridTextColumn>
            </dg:DataGrid.Columns>
            <dg:DataGrid.BindingGroup>
                <BindingGroup />
            </dg:DataGrid.BindingGroup>
        </dg:DataGrid>
    </Grid>


</Window>



this code create a DataGrid with the given setting. this DataGrid become visible when the code is executed. now I want to load different DataBase based on the different menu click in the same window.how I can approach this situation

any type of helps are highly appreciated

Iqbal
Posted

It is all in the data context and the data bindings. For your grid you have set the DataContext = "{Binding}" which means the grid inherits the data context of the parent... most likely either the root user control or higher up the chain (like in App.xaml). In code somewhere you are setting the data context for the page or the root grid or something. (object.DataContext = MyDataContext) You have to be doing this if the binding is working and the grid is displaying data. You just need to extend this a bit so the data grid can detect that a change in the data source has occurred.

In response to the menu action you have to change the data context that the data grid is bound to. Since you are just using {Binding} without specifying a member, I'm guessing you are binding against a data object or some other class that implements IEnumerable. You should, really, be exposing the data set as a property on a class that implements INotifyPropertyChanged then binding the data context of the grid to that property. (DataContext = "{Binding DataPropertyName}" Then in the property setter for the data set property you raise NotifyPropertyChanged so the data grid knows the data set has changed.

There are lots of tutorials out there on binding data to a data grid and on exposing properties on a controller class that implements INotifyPropertyChanged. I would suggest you read up on that to understand how all of this works. Going much further than this is too involved for this forum. I would suggest searching for MVVM too and reading up on how it is implemented. You're almost there but you are going to need to educate yourself on some of these concepts if you want to make this work and work well.
 
Share this answer
 
If course you can do it. All UI libraries are designed to lay out any reasonable number of controls on the same window or form. For this purpose, there is a number of containers where you can put other controls; in WPF, these are System.Windows.Controls.DockPanel, System.Windows.Controls.Grid and more, they are derived from System.Windows.Controls.Panel, see http://msdn.microsoft.com/en-us/library/system.windows.controls.panel.aspx#inheritanceContinued[^].

A very good variant is the class System.Windows.Controls.TabControl which you can use to put controls on different tab pages, see http://msdn.microsoft.com/en-us/library/system.windows.controls.tabcontrol.aspx[^].

However, I look at your code and doubt that advice like that could help you at all.

For example, you had enough patience to insert 104 nearly identical lines like <ColumnDefinition Width="&hellip;" /> or <RowDefinition Width="&hellip;" />. (By the way, how can you imagine the user who would look at so many columns at the same time?) You added them manually and edited the Width attribute of each item manually as if you would be really able to support it and change widths if the strings are changed. This is hopeless.

What you are trying to do has nothing to do with programming. You are doing too much manual job which has not value. You are trying to use hands instead of brain. This is something directly opposite to programming. I don't know where can you start but you need to learn programming, maybe from the very beginning. There is no other way.

And first thing you should understand: the programming is not done using the Designer. Programming is not done by clicking mouse. Programming is not done by repeating copy and paste operation. It is not done by repeating any line several times. Programming is something directly opposite, fundamentally using generalization and abstraction.

You cannot continue and complete this project the way you are doing right now. You cannot continue without going back to based. Listen to a good friendly advice: don't waste your time, go back to the very basics.

http://en.wikipedia.org/wiki/Don%27t_repeat_yourself[^],
http://norvig.com/21-days.html[^].

—SA
 
Share this answer
 
Comments
[no name] 17-Jan-12 11:52am    
I started learning wpf since last one week if my question made anybody embarrassed i am extreamly sorry

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900