My code:
MainWindow.xaml
<Window x:Class="TestStyle.MainWindow" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" xmlns:telerikGrid="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView" Title="MainWindow" Height="350" Width="525"> <StackPanel> <StackPanel Orientation="Horizontal" HorizontalAlignment="Center"> <telerik:RadButton Width="150" Content="Add new row" Command="telerikGrid:RadGridViewCommands.BeginInsert" CommandTarget="{Binding ElementName=RadGridView1}" /> </StackPanel> <telerikGrid:RadGridView SelectionMode="Single" AddingNewDataItem="RadGridView1_AddingNewDataItem" x:Name="RadGridView1" AutoGenerateColumns="False"> <telerikGrid:RadGridView.Columns> <telerikGrid:GridViewComboBoxColumn Header="Screen" UniqueName="Screen" x:Name="screen" DataMemberBinding="{Binding IdGrid}" DisplayMemberPath="Name" SelectedValueMemberPath="IdListBox" > <telerikGrid:GridViewComboBoxColumn.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <TextBlock Text="{Binding Name}" x:Name="textblockTooltip" Width="Auto" Padding="1,1,1,1" > <TextBlock.ToolTip> <ToolTip> <ToolTip.Template> <ControlTemplate TargetType="ToolTip"> <Border CornerRadius="2,2,2,2" Width="100" Height="75" x:Name="borderTooltip" Background="Green" BorderBrush="#FF000000" Margin="2"> <ContentPresenter Content="{Binding GridView}" Margin="2" /> </Border> </ControlTemplate> </ToolTip.Template> </ToolTip> </TextBlock.ToolTip> </TextBlock> </StackPanel> </DataTemplate> </telerikGrid:GridViewComboBoxColumn.ItemTemplate> </telerikGrid:GridViewComboBoxColumn> </telerikGrid:RadGridView.Columns> </telerikGrid:RadGridView> </StackPanel> </Window> MainWindow.xaml.cs
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using System.Collections.ObjectModel; using Telerik.Windows.Controls; namespace TestStyle { /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { bool resolution = false; public bool Resolution { get { return resolution; } set { resolution = value; } } public MainWindow() { InitializeComponent(); ICommand beginInsertCommand = RadGridViewCommands.BeginInsert; ObservableCollection<ItemGrid> collectionGrid = new ObservableCollection<ItemGrid>(); RadGridView1.ItemsSource = collectionGrid; ObservableCollection<ItemListBox> collectionListBox = new ObservableCollection<ItemListBox>(); Label l1 = new Label(); l1.Content = "Label 1"; Label l2 = new Label(); l2.Content = "Label 2"; Grid gr1 = new Grid(); gr1.Children.Add(l1); Grid gr2 = new Grid(); gr2.Children.Add(l2); collectionListBox.Add(new ItemListBox(1, "Name 1", gr1)); collectionListBox.Add(new ItemListBox(2, "Name 2", gr2)); screen.ItemsSource = collectionListBox; } private void RadGridView1_AddingNewDataItem(object sender, Telerik.Windows.Controls.GridView.GridViewAddingNewEventArgs e) { e.NewObject = new ItemGrid(0); } } } ItemGrid.cs
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Controls; using System.ComponentModel; namespace TestStyle { class ItemGrid : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; private int idGrid; public int IdGrid { get { return idGrid; } set { idGrid = value; NotifyPropertyChanged("IdGrid"); } } public ItemGrid(int id) { this.idGrid = id; } private void NotifyPropertyChanged(string info) { if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs(info)); } } } ItemListBox.cs
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Controls; using System.ComponentModel; namespace TestStyle { class ItemListBox : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; int idListBox; public int IdListBox { get { return idListBox; } set { idListBox = value; NotifyPropertyChanged("IdListBox"); } } string name; public string Name { get { return name; } set { name = value; NotifyPropertyChanged("Name"); } } Grid gridView; public Grid GridView { get { return gridView; } set { gridView = value; NotifyPropertyChanged("GridView"); } } public ItemListBox(int idListBox, string name, Grid gridView) { this.idListBox = idListBox; this.gridView = gridView; this.name = name; } private void NotifyPropertyChanged(string info) { if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs(info)); } } }I need to change Height property at Border "borderTooltip" according to value of property Resolution in ManWindow.xaml.cs.
I tried in constructor MainWindow() this:
if (Resolution == true) borderTooltip.Height = 75; else borderTooltip.Height = 50;But i can´t access borderTooltip in code.Does somebody know please how to change borderTooltip.Height according to value of Resolution property?