Hi ,
I am using GridViwTogglerowDetailsColumn based on year value (2010, 2014, 2018) need to display the year related data but how do i accomplish this .
Here I have a student marks details for year 2010 ,2014 and 2018 when I select 2010 year node it neeed to display onlt that year marks list and remaing years need to go disable . but here displaying all years records in all rows
In code behind i would like to write like this (x:Name="lastYear",x:Name="CurrentYear",x:Name="NextYear")
if(Year >2014)
{
this.lastYear.Visiblity= visibilty.Collapsed;
}
But system displaying an error "Error 1 'MasterViewDemoMVVM.StudentView' does not contain a definition for 'lastYear' and no extension method 'lastYear' accepting a first argument of type 'MasterViewDemoMVVM.StudentView' could be found (are you missing a using directive or an assembly reference?) C:\Users\mandapellyr\Documents\Visual Studio 2012\Projects\MasterViewDemoMVVM\MasterViewDemoMVVM\StudentView.xaml.cs 41 22 MasterViewDemoMVVM
"
How can i over come this
Kindly help me .
<UserControl x:Class="MasterViewDemoMVVM.StudentView" xmlns:VM="clr-namespace:MasterViewDemoMVVM" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="400"> <UserControl.Resources> <VM:ClientViewModel x:Key="VMKEY"/> <Style x:Key="LableStyle" TargetType="sdk:Label"> <Setter Property="Width" Value="AUTO"/> <Setter Property="Height" Value="Auto"/> <Setter Property="FontFamily" Value="Segoe UI"/> <Setter Property="HorizontalAlignment" Value="Left"/> <Setter Property="VerticalAlignment" Value="Center"/> <Setter Property="Margin" Value="5,0,5,0" /> </Style> <Style x:Key="TextBlockStyle" TargetType="TextBlock"> <!--Margin="5" VerticalAlignment="Center"--> <Setter Property="Margin" Value="5"/> <Setter Property="Width" Value="Auto" /> <Setter Property="VerticalAlignment" Value="Center" /> </Style> <Style x:Key="TextBoxStyle" TargetType="TextBox"> <Setter Property="Margin" Value="5,5"/> <Setter Property="Width" Value="120" /> <Setter Property="HorizontalAlignment" Value="Left" /> </Style> </UserControl.Resources> <Grid x:Name="LayoutRoot" Background="White"> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="300*" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="10" /> </Grid.RowDefinitions> <Grid Grid.Row="0"> <Border Name="brdrHeading"> <Grid Margin="1"> <Grid.Background> <LinearGradientBrush EndPoint="0.8,1" StartPoint="0.5,0"> <GradientStop Color="#FF00008B" Offset="-0.5" /> <GradientStop Color="#FFADD8E6" Offset="1" /> </LinearGradientBrush> </Grid.Background> <TextBlock Text="Student View" FontFamily="Segoe UI" FontSize="18" Margin="10,5" Foreground="White" /> </Grid> </Border> </Grid> <telerik:RadGridView x:Name="dgStudentViewSummary" DataContext="{StaticResource VMKEY}" GroupRenderMode="Flat" ItemsSource="{Binding ClientModel }" VerticalAlignment="Top" MaxHeight="700" Margin="2" ColumnWidth="Auto" CanUserFreezeColumns="False" telerik:StyleManager.Theme="Windows8" AutoGenerateColumns="False" RowIndicatorVisibility="Collapsed" CanUserDeleteRows="False" CanUserInsertRows="False" IsReadOnly="True"> <telerik:RadGridView.Columns> <telerik:GridViewToggleRowDetailsColumn /> <telerik:GridViewDataColumn Header="Student Name" Width="150" DataMemberBinding="{Binding StudentName}" TextAlignment="Right"/> </telerik:RadGridView.Columns> <telerik:RadGridView.RowDetailsTemplate> <DataTemplate> <telerik:RadTabControl x:Name="RadTabControl1" Width="1550" HorizontalAlignment="Left" Margin="10" VerticalAlignment="Center"> <telerik:RadTabItem Header="Student Details"> <telerik:RadGridView x:Name="dgMasterStudentViewSummary" DataContext="{StaticResource VMKEY}" GroupRenderMode="Flat" ItemsSource="{Binding ClientModel }" VerticalAlignment="Top" MaxHeight="700" Margin="2" ColumnWidth="Auto" CanUserFreezeColumns="False" telerik:StyleManager.Theme="Windows8" AutoGenerateColumns="False" RowIndicatorVisibility="Collapsed" CanUserDeleteRows="False" CanUserInsertRows="False" IsReadOnly="True"> <telerik:RadGridView.Columns> <telerik:GridViewToggleRowDetailsColumn/> <telerik:GridViewDataColumn Header="Year" Width="150" DataMemberBinding="{Binding Year,Mode=TwoWay}" TextAlignment="Right"/> <telerik:GridViewDataColumn Header="Address" Width="150" DataMemberBinding="{Binding ClientName}" TextAlignment="Right"/> </telerik:RadGridView.Columns> <telerik:RadGridView.RowDetailsTemplate> <DataTemplate> <ScrollViewer Height="200"> <Grid VerticalAlignment="Top" Margin="5" > <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> </Grid.RowDefinitions> <Grid Grid.Row="0"> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="10" /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="140" /> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <sdk:Label Content="Year:" Style="{StaticResource LableStyle}" Grid.Column="0" Grid.Row="1" /> <TextBlock Text="{Binding Year}" Style="{StaticResource TextBlockStyle}" Grid.Column="1" Grid.Row="1" /> </Grid> <Grid x:Name="lastYear" Grid.Row="1" Visibility="Visible"> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> <RowDefinition Height="10"/> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" /> </Grid.ColumnDefinitions> <sdk:Label Content="Maths:" Style="{StaticResource LableStyle}" Grid.Column="0" Grid.Row="0" /> <TextBlock x:Name="lastyearMaths" Style="{StaticResource TextBlockStyle}" Text="{Binding Maths}" TextAlignment="Right" Grid.Column="1" Grid.Row="0" /> <sdk:Label Content="Science:" Style="{StaticResource LableStyle}" Grid.Column="0" Grid.Row="1" /> <TextBlock x:Name="lastYearScienceTB" Style="{StaticResource TextBlockStyle}" Text="{Binding Science}" TextAlignment="Right" Grid.Column="1" Grid.Row="1" /> <sdk:Label Content="English:" Style="{StaticResource LableStyle}" Grid.Column="0" Grid.Row="2" /> <TextBlock x:Name="lastYearEnglishTB" Style="{StaticResource TextBlockStyle}" Text="{Binding English}" TextAlignment="Right" Grid.Column="1" Grid.Row="2" /> </Grid> <Grid x:Name="CurrentYear" Grid.Row="2" Visibility="Visible"> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" /> </Grid.ColumnDefinitions> <sdk:Label Content="Maths:" Style="{StaticResource LableStyle}" Grid.Column="0" Grid.Row="0" /> <TextBlock x:Name="CurrentyearMaths" Style="{StaticResource TextBlockStyle}" Text="{Binding Maths}" TextAlignment="Right" Grid.Column="1" Grid.Row="0" /> <sdk:Label Content="Science:" Style="{StaticResource LableStyle}" Grid.Column="0" Grid.Row="1" /> <TextBlock x:Name="CurrentYearScienceTB" Style="{StaticResource TextBlockStyle}" Text="{Binding Science}" TextAlignment="Right" Grid.Column="1" Grid.Row="1" /> <sdk:Label Content="English:" Style="{StaticResource LableStyle}" Grid.Column="0" Grid.Row="2" /> <TextBlock x:Name="CurrentYearEnglishTB" Style="{StaticResource TextBlockStyle}" Text="{Binding English}" TextAlignment="Right" Grid.Column="1" Grid.Row="2" /> </Grid> <Grid x:Name="nextyear" Grid.Row="3" Visibility="Visible"> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" /> </Grid.ColumnDefinitions> <sdk:Label Content="Maths:" Style="{StaticResource LableStyle}" Grid.Column="0" Grid.Row="0" /> <TextBlock x:Name="NextyearMaths" Style="{StaticResource TextBlockStyle}" Text="{Binding Maths}" TextAlignment="Right" Grid.Column="1" Grid.Row="0" /> <sdk:Label Content="Science:" Style="{StaticResource LableStyle}" Grid.Column="0" Grid.Row="1" /> <TextBlock x:Name="NextYearScienceTB" Style="{StaticResource TextBlockStyle}" Text="{Binding Science}" TextAlignment="Right" Grid.Column="1" Grid.Row="1" /> <sdk:Label Content="English:" Style="{StaticResource LableStyle}" Grid.Column="0" Grid.Row="2" /> <TextBlock x:Name="NextYearEnglishTB" Style="{StaticResource TextBlockStyle}" Text="{Binding English}" TextAlignment="Right" Grid.Column="1" Grid.Row="2" /> </Grid> </Grid> </ScrollViewer> </DataTemplate> </telerik:RadGridView.RowDetailsTemplate> </telerik:RadGridView> </telerik:RadTabItem> <telerik:RadTabItem Header="Teacher Details"> <telerik:RadGridView x:Name="dgMasterTSViewSummary" DataContext="{StaticResource VMKEY}" GroupRenderMode="Flat" ItemsSource="{Binding ClientModel }" VerticalAlignment="Top" MaxHeight="700" Margin="2" ColumnWidth="Auto" CanUserFreezeColumns="False" telerik:StyleManager.Theme="Windows8" AutoGenerateColumns="False" RowIndicatorVisibility="Collapsed" CanUserDeleteRows="False" CanUserInsertRows="False" IsReadOnly="True"> <telerik:RadGridView.Columns> <telerik:GridViewToggleRowDetailsColumn/> <telerik:GridViewDataColumn Header="Year" Width="150" DataMemberBinding="{Binding Year, Mode=TwoWay}" TextAlignment="Right" /> <telerik:GridViewDataColumn Header="Address" Width="150" DataMemberBinding="{Binding ClientAddress}" TextAlignment="Right"/> </telerik:RadGridView.Columns> <telerik:RadGridView.RowDetailsTemplate> <DataTemplate> <ScrollViewer MaxHeight="300"> <Grid VerticalAlignment="Top" Margin="5" > <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> </Grid.RowDefinitions> <Grid Grid.Row="0"> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="10" /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="140" /> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" /> </Grid.ColumnDefinitions> <sdk:Label Content="Year:" Style="{StaticResource LableStyle}" Grid.Column="0" Grid.Row="1" /> <TextBlock Style="{StaticResource TextBlockStyle}" Text="{Binding Year}" Grid.Column="1" Grid.Row="1" /> </Grid> <Grid x:Name="lastYear" Grid.Row="1" Visibility="Visible"> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> <RowDefinition Height="10"/> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <sdk:Label Content="Maths:" Style="{StaticResource LableStyle}" Grid.Column="0" Grid.Row="0" /> <TextBlock x:Name="lastyearMaths" Style="{StaticResource TextBlockStyle}" Text="{Binding Maths}" TextAlignment="Right" Grid.Column="1" Grid.Row="0" /> <sdk:Label Content="Science:" Style="{StaticResource LableStyle}" Grid.Column="0" Grid.Row="1" /> <TextBlock x:Name="lastYearScienceTB" Style="{StaticResource TextBlockStyle}" Text="{Binding Science}" TextAlignment="Right" Grid.Column="1" Grid.Row="1" /> <sdk:Label Content="English:" Style="{StaticResource LableStyle}" Grid.Column="0" Grid.Row="2" /> <TextBlock x:Name="lastYearEnglishTB" Style="{StaticResource TextBlockStyle}" Text="{Binding English}" TextAlignment="Right" Grid.Column="1" Grid.Row="2" /> </Grid> <Grid x:Name="CurrentYear" Grid.Row="2" Visibility="Visible"> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" /> </Grid.ColumnDefinitions> <sdk:Label Content="Maths:" Style="{StaticResource LableStyle}" Grid.Column="0" Grid.Row="0" /> <TextBlock x:Name="CurrentyearMaths" Style="{StaticResource TextBlockStyle}" Text="{Binding Maths}" TextAlignment="Right" Grid.Column="1" Grid.Row="0" /> <sdk:Label Content="Science:" Style="{StaticResource LableStyle}" Grid.Column="0" Grid.Row="1" /> <TextBlock x:Name="CurrentYearScienceTB" Style="{StaticResource TextBlockStyle}" Text="{Binding Science}" TextAlignment="Right" Grid.Column="1" Grid.Row="1" /> <sdk:Label Content="English:" Style="{StaticResource LableStyle}" Grid.Column="0" Grid.Row="2" /> <TextBlock x:Name="CurrentYearEnglishTB" Style="{StaticResource TextBlockStyle}" Text="{Binding English}" TextAlignment="Right" Grid.Column="1" Grid.Row="2" /> </Grid> <Grid x:Name="nextyear" Grid.Row="3" Visibility="Visible"> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" /> </Grid.ColumnDefinitions> <sdk:Label Content="Maths:" Style="{StaticResource LableStyle}" Grid.Column="0" Grid.Row="0" /> <TextBlock x:Name="NextyearMaths" Style="{StaticResource TextBlockStyle}" Text="{Binding Maths}" TextAlignment="Right" Grid.Column="1" Grid.Row="0" /> <sdk:Label Content="Science:" Style="{StaticResource LableStyle}" Grid.Column="0" Grid.Row="1" /> <TextBlock x:Name="NextYearScienceTB" Style="{StaticResource TextBlockStyle}" Text="{Binding Science}" TextAlignment="Right" Grid.Column="1" Grid.Row="1" /> <sdk:Label Content="English:" Style="{StaticResource LableStyle}" Grid.Column="0" Grid.Row="2" /> <TextBlock x:Name="NextYearEnglishTB" Style="{StaticResource TextBlockStyle}" Text="{Binding English}" TextAlignment="Right" Grid.Column="1" Grid.Row="2" /> </Grid> </Grid> </ScrollViewer> </DataTemplate> </telerik:RadGridView.RowDetailsTemplate> </telerik:RadGridView> </telerik:RadTabItem> </telerik:RadTabControl> </DataTemplate> </telerik:RadGridView.RowDetailsTemplate> </telerik:RadGridView> </Grid></UserControl>using System;using System.Net;using System.Windows;using System.Windows.Controls;using System.Windows.Documents;using System.Windows.Ink;using System.Windows.Input;using System.Windows.Media;using System.Windows.Media.Animation;using System.Windows.Shapes;using System.Collections.Generic;using System.Collections.ObjectModel;namespace MasterViewDemoMVVM{ public class ClientViewModel { private ObservableCollection<ModelClientName> _clintmodel; public ObservableCollection<ModelClientName> ClientModel { get { return _clintmodel; } set { _clintmodel = value; } } ModelClientName m; public ClientViewModel() { m = new ModelClientName(); ClientModel = m.GetAllClient(); } }}using System;using System.Net;using System.Windows;using System.Windows.Controls;using System.Windows.Documents;using System.Windows.Ink;using System.Windows.Input;using System.Windows.Media;using System.Windows.Media.Animation;using System.Windows.Shapes;using System.Collections.Generic;using System.Collections.ObjectModel;namespace MasterViewDemoMVVM{ public class ModelClientName { public string StudentName { get; set; } public string StudentAddress { get; set; } public int Year { get; set; } public int Maths { get; set; } public int Science { get; set; } public int English { get; set; } public ObservableCollection<ModelClientName> GetAllClient() { ObservableCollection<ModelClientName> _clnt = new ObservableCollection<ModelClientName>(); _clnt.Add(new ModelClientName() { StudentAddress = "Hyd", StudentName = "Raja", Year = 2010,Maths=50,Science=50,English=50 }); _clnt.Add(new ModelClientName() { StudentAddress = "Hyd", StudentName = "Raja", Year = 2014 ,Science=60, Maths=60, English=60 }); _clnt.Add(new ModelClientName() { StudentAddress = "Hyd", StudentName = "Raja", Year = 2018, Science = 70, Maths = 70, English = 70 }); return _clnt; } }}