This is a migrated thread and some comments may be shown as answers.

Ivalueconverter Not triggering For Visible In TabControl

1 Answer 40 Views
TabControl
This is a migrated thread and some comments may be shown as answers.
Ramesh
Top achievements
Rank 1
Ramesh asked on 19 Dec 2013, 08:46 AM
Hi Telerik,

 Iam using TabControl , based on TabItem value I Need to Visible / Collapse The tabContent Controls Like Grid in my case .
For this Iam using I value Converter Class but this is not triggering in debugmode n not getting expected out put .

 In Out Put window Iam getting bellow error "
"

System.Windows.Data Error: BindingExpression path error: 'Hide' property not found on 'MasterViewScreenDesignNavigation.Model.MasterModel' 'MasterViewScreenDesignNavigation.Model.MasterModel' (HashCode=35259143). BindingExpression: Path='Hide' DataItem='MasterViewScreenDesignNavigation.Model.MasterModel' (HashCode=35259143); target element is 'System.Windows.Controls.TextBlock' (Name=''); target property is 'Visibility' (type 'System.Windows.Visibility')..

"
Iam not understanding what is this error

My sample cosde bellow




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.ObjectModel;
using System.Collections.Generic;
using MasterViewScreenDesignNavigation.Model;
 
 
namespace MasterViewScreenDesignNavigation.VIewMOdel
{
    public class MasterViewModel: System.ComponentModel.INotifyPropertyChanged
    {
        MasterModel m = new MasterModel();
         
 
        public MasterViewModel()
        {        
 
            MAsterLIst = new ObservableCollection<MasterModel>();
             MAsterLIst = m.GetAll();
             Hide = false;
         
        }
     private ObservableCollection<MasterModel> _MAsterLIst ;
 
       public ObservableCollection<MasterModel> MAsterLIst
        {
            get { return _MAsterLIst; }
            set
            {
                _MAsterLIst = value;
                RaisePropertyChanged("MAsterLIst");
            }
         
      }
 
 
       public MasterModel _ReportYear;
 
       public MasterModel SelectedReportYear
       {
           get
           {
               return _ReportYear;
           }
           set
           {
               _ReportYear = value;
               RaisePropertyChanged("SelectedReportYear");
 
               if (SelectedReportYear.Year < 5)
               {
                   Hide = true;
               }
               ValueHide();
           }
        
       }
 
       public bool _Hide;
       public bool Hide
       {
           get { return _Hide; }
           set { _Hide = value; RaisePropertyChanged("Hide"); }
       }
 
 
       public void ValueHide()
       {
           
       }
         #region INotifyPropertyChanged Members
 
        public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
        private void RaisePropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
        }
 
        #endregion
     
    }
}


public sealed class BooleanToVisibilityConverter : IValueConverter
 
{
    public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        if (value is bool)
        {
            bool boolValue = (bool)value;
            return (boolValue == true) ? Visibility.Visible : Visibility.Collapsed;
        }
        return value;
    }
 
    public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        throw new NotImplementedException();
    }





<UserControl x:Class="MasterViewScreenDesignNavigation.MainPage"
             xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
        xmlns:Con="clr-namespace:MasterViewScreenDesignNavigation.Common"
              
            xmlns:VM="clr-namespace:MasterViewScreenDesignNavigation.VIewMOdel"
              
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">
     
    <UserControl.Resources>
        <VM:MasterViewModel x:Key="vm" />
         
        <Con:BooleanToVisibilityConverter x:Key="BoolVis"/>
        <DataTemplate x:Key="data" >
 
            <Grid  >
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="30" />
                </Grid.RowDefinitions>
                <Grid  >
 
                    <TextBlock Text="{Binding Name}"
                               Visibility="{Binding Hide, Converter={StaticResource BoolVis}}" />
 
                </Grid>
 
                <Grid Grid.Row="1">
                    <TextBlock Text="{Binding Year}"/>
                </Grid>
            </Grid>
        </DataTemplate>
 
 
 
    </UserControl.Resources>
 
    <!--<UserControl.DataContext>
        <VM:MasterViewModel/>
    </UserControl.DataContext>-->
 
 
    <Grid x:Name="LayoutRoot" DataContext="{StaticResource vm}" >
 
        <Grid.Background>
            <ImageBrush ImageSource="/StrategyDevelopment;component/Images/Background.png" />
        </Grid.Background>
      
        <Grid Grid.Row="1">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*"/>
                <RowDefinition Height="10" />
                <RowDefinition Height="30" />
            </Grid.RowDefinitions>
 
            <telerik:RadTabControl Grid.Row="0"   ItemsSource="{Binding MAsterLIst,Mode=TwoWay}" 
                                   DisplayMemberPath="Year"
                                ContentTemplate="{StaticResource data}"
                                    SelectedItem="{Binding SelectedReportYear, Mode=TwoWay}">           
                 
 
            </telerik:RadTabControl>            
       
 
 
        </Grid>
 
         
 
 
 
 
    </Grid>
</UserControl>

1 Answer, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 23 Dec 2013, 10:28 AM
Hello Ramesh,

From the other forum you started (Display Data based on TabControl Header) I understand you have handled the above mentioned issue. 

Also, it would be best to keep the communication only in the other forum thread as this would allow us to easily track your case and whether it is resolved. We usually recommend describing one issue in one thread to make the communication process more consistent and we also encourage our customers to start multiple threads only when these threads are describing different issues.

Regards,
Martin Ivanov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
TabControl
Asked by
Ramesh
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Share this question
or