<
telerik:RadGridView.RowDetailsTemplate>
<DataTemplate>
<telerik:RadGridView Margin="4,5,5,4" ShowColumnFooters="False" ShowGroupPanel="False" AutoGenerateColumns="False" ShowInsertRow="False" ItemsSource="{Binding IoTerminals}">
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn Header="Name" DataMemberBinding="{Binding Name}"/>
<telerik:GridViewCheckBoxColumn Header="Simulated" DataMemberBinding="{Binding Simulated}"/>
<telerik:GridViewCheckBoxColumn Header="Sim is possible" DataMemberBinding="{Binding SimPossible}" />
</telerik:RadGridView.Columns>
</telerik:RadGridView>
</DataTemplate>
</telerik:RadGridView.RowDetailsTemplate>
(Edit: I have made two edits on this post to try to make the above xaml look approachable, but to little avail)
The two Checkbox columns shows up empty. In the debugger I see that the property "SimPossible" is executed correctly and that it return "true". The "Name" column shows the correct value (boolean True).
If I change AutoGenerateColumns to True, then the additional generated columns shows correct value (and checked status).
No binding error is displayed in the debugger output window.
Is there any further parameterization necessary to map boolean "True" to display checked status? Do I need a value converter?
As you can see, this is in the rowdetails section of another GridView (in case that is relevant).
(New Info : Replacing the GridViewCheckBoxColumn with regular GridViewDataColumn is displayed correctly)
I use Q1 2012.
<telerik:RadListBox x:Name="lb1" Width="116" HorizontalAlignment="Left" IsEnabled="True" telerik:StyleManager.Theme="Windows7" ItemsSource="{Binding}"> <telerik:RadListBox.ItemTemplate> <StaticResource ResourceKey="Template1"/> </telerik:RadListBox.ItemTemplate> </telerik:RadListBox><Grid.Resources> <DataTemplate x:Key="Template1"> <WrapPanel> <Grid> <Grid.RowDefinitions> <RowDefinition Height="20"/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/> </Grid.ColumnDefinitions> <TextBlock Grid.Column="0" Text="{Binding Path=A1}"/> <TextBlock Grid.Column="1" Text="{Binding Path=B1}" Margin="4,0,0,0"/> </Grid> </WrapPanel> </DataTemplate> </Grid.Resources>ToolTipService.ShowDuration="20000"<Style x:Key="Level200HorizontalStyle" TargetType="telerik:AppointmentItem"> <Setter Property="Background" Value="{StaticResource AppointmentBackground}" /> <Setter Property="BorderBrush" Value="{StaticResource AppointmentBorder}" /> <Setter Property="Padding" Value="5" /> <Setter Property="Foreground" Value="{StaticResource AppointmentForeground}" /> <Setter Property="FontSize" Value="10" /> <!-- Setter Property="FontFamily" Value="Arial"/ --> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type telerik:AppointmentItem}"> <Grid x:Name="Root" ToolTipService.ShowDuration="20000"
> <Grid.InputBindings> <MouseBinding MouseAction="LeftDoubleClick" Command="scheduleView:RadScheduleViewCommands.EditAppointment"/> </Grid.InputBindings> <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" CornerRadius="2" /> <Border x:Name="CommonStatesVisual" BorderThickness="{TemplateBinding BorderThickness}" Background="{StaticResource AppointmentMouseOver}" BorderBrush="{TemplateBinding BorderThickness}" CornerRadius="2" Visibility="Collapsed" /> <Grid HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Margin="{TemplateBinding Padding}"> <Grid.ColumnDefinitions> <ColumnDefinition Width="20" /> <ColumnDefinition Width="Auto" /> </Grid.ColumnDefinitions> <ContentPresenter /> </Grid> <Grid x:Name="MouseOverOverlay" Opacity="0" Visibility="Collapsed"> <Border x:Name="PART_StartResizeGrip" telerik:RadDragAndDropManager.AllowDrag="True" Background="Transparent" Cursor="SizeWE" HorizontalAlignment="Left" VerticalAlignment="Stretch"> <StackPanel x:Name="StartResizeGrip" HorizontalAlignment="Center" Margin="1" VerticalAlignment="Center" Background="#FF878787"> <Rectangle Fill="White" Height="2" Margin="1" Width="2" /> <Rectangle Fill="White" Height="2" Margin="1" Width="2" /> <Rectangle Fill="White" Height="2" Margin="1" Width="2" /> </StackPanel> </Border> <Border x:Name="PART_EndResizeGrip" telerik:RadDragAndDropManager.AllowDrag="True" Background="Transparent" Cursor="SizeWE" HorizontalAlignment="Right" VerticalAlignment="Stretch"> <StackPanel x:Name="EndResizeGrip" HorizontalAlignment="Center" Margin="1" VerticalAlignment="Center" Background="#FF878787"> <Rectangle Fill="White" Height="2" Margin="1" Width="2" /> <Rectangle Fill="White" Height="2" Margin="1" Width="2" /> <Rectangle Fill="White" Height="2" Margin="1" Width="2" /> </StackPanel> </Border> </Grid> </Grid> <ControlTemplate.Triggers> <Trigger Property="IsDragged" Value="True"> <Setter Property="Opacity" TargetName="Root" Value="0.3" /> </Trigger> <Trigger Property="IsMouseOver" Value="True"> <Trigger.EnterActions> <BeginStoryboard> <Storyboard> <ObjectAnimationUsingKeyFrames Duration="0:0:0.4" Storyboard.TargetProperty="Visibility" Storyboard.TargetName="MouseOverOverlay"> <DiscreteObjectKeyFrame KeyTime="0"> <DiscreteObjectKeyFrame.Value> <Visibility>Visible</Visibility> </DiscreteObjectKeyFrame.Value> </DiscreteObjectKeyFrame> </ObjectAnimationUsingKeyFrames> <DoubleAnimation BeginTime="0:0:0.2" Duration="0:0:0.2" To="1" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="MouseOverOverlay" /> </Storyboard> </BeginStoryboard> </Trigger.EnterActions> <Trigger.ExitActions> <BeginStoryboard> <Storyboard> <ObjectAnimationUsingKeyFrames Duration="0:0:0.2" Storyboard.TargetProperty="Visibility" Storyboard.TargetName="MouseOverOverlay"> <DiscreteObjectKeyFrame KeyTime="0:0:0.2"> <DiscreteObjectKeyFrame.Value> <Visibility>Collapsed</Visibility> </DiscreteObjectKeyFrame.Value> </DiscreteObjectKeyFrame> </ObjectAnimationUsingKeyFrames> <DoubleAnimation BeginTime="0" Duration="0:0:0.2" To="0" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="MouseOverOverlay" /> </Storyboard> </BeginStoryboard> </Trigger.ExitActions> <Setter Property="Visibility" TargetName="CommonStatesVisual" Value="Visible" /> <Setter Property="Visibility" TargetName="MouseOverOverlay" Value="Visible" /> </Trigger> <Trigger Property="IsSelected" Value="True"> <Setter Property="Visibility" TargetName="CommonStatesVisual" Value="Visible" /> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style><
telerik:RadGridView x:Name="radGridViewList" Margin="5 0 5 5" Visibility="Visible" RowDetailsVisibilityMode="Collapsed" FrozenColumnCount="1"
RowIndicatorVisibility="Collapsed" IsReadOnly="True" AutoGenerateColumns="False" CanUserFreezeColumns="False" Grid.Row="3"
CanUserResizeColumns="True" ShowColumnFooters="True" ShowGroupFooters="True" SelectionMode="Extended" IsSynchronizedWithCurrentItem="True"> />
static public void SetColumns(RadGridView pGrid, ColumnDescriptor[] pColumnNames)
{
if (pColumnNames != null)
{
EnumerableAggregateFunctionBase aggFunc;
for (int iColumnIndex = 0; iColumnIndex < pColumnNames.Length; iColumnIndex++)
{
ColumnDescriptor oneName = pColumnNames[iColumnIndex];
GridViewDataColumn oneColumn = new Telerik.Windows.Controls.GridViewDataColumn();
oneColumn.Header = oneName.ColumnName;
//Apply proper column display format.
switch (oneName.Format.ToUpper())
{
case "$":
oneColumn.DataFormatString = "C2";
break;
case "D":
oneColumn.DataFormatString = "yyyy'-'MM'-'dd";
break;
case "H":
oneColumn.DataFormatString = "HH':'mm";
break;
case "DH":
oneColumn.DataFormatString = "yyyy'-'MM'-'dd' 'HH':'mm";
break;
}
oneColumn.Width = new GridViewLength(1, GridViewLengthUnitType.Star);
oneColumn.ShowFilterButton = true;
oneColumn.IsSortable = true;
oneColumn.IsFilterable = true;
oneColumn.DataMemberBinding = new Binding(string.Format("ElementCells[{0:D}]", iColumnIndex));
oneColumn.TextAlignment = (TextAlignment)oneName.TextAlignment;
oneColumn.HeaderTextAlignment = (TextAlignment)oneName.TextAlignment;
//Create proper aggregate functions.
if (oneName.Agregation != AgregationFunction.None)
{
aggFunc = null;
switch (oneName.Agregation)
{
case AgregationFunction.Average:
aggFunc = new AverageFunction()
{
Caption = LocGeneral.GetControlText("Average") + ": "
};
break;
case AgregationFunction.Count:
aggFunc = new CountFunction()
{
Caption = LocGeneral.GetControlText("Count") + ": "
};
break;
case AgregationFunction.FirstValue:
aggFunc = new FirstFunction()
{
Caption = LocGeneral.GetControlText("First") + ": "
};
break;
case AgregationFunction.LastValue:
aggFunc = new LastFunction()
{
Caption = LocGeneral.GetControlText("Last") + ": "
};
break;
case AgregationFunction.MaxValue:
aggFunc = new MaxFunction()
{
Caption = LocGeneral.GetControlText("Max") + ": "
};
break;
case AgregationFunction.MinValue:
aggFunc = new MinFunction()
{
Caption = LocGeneral.GetControlText("Min") + ": "
};
break;
case AgregationFunction.Sum:
aggFunc = new SumFunction()
{
Caption = LocGeneral.GetControlText("Sum") + ": ",
SourceFieldType = typeof(Decimal)
};
break;
}
//If aggregate function created, we add it to the column.
if (aggFunc != null)
{
oneColumn.AggregateFunctions.Add(aggFunc);
}
}
pGrid.Columns.Add(oneColumn);
}
}
}
using System;
using System.Diagnostics;
using System.Runtime.Serialization;
namespace com.christiegrp.Neuron.Client
{
[DataContract]
public class CompleteConfiguration : NeuronClientBase
{
#region Constructors.
public CompleteConfiguration(bool pReadFromDatabase)
: base(pReadFromDatabase)
{
}
#endregion
#region NeuronClientBase overrides.
protected override string getListBoxDisplay()
{
return Name;
}
protected override string[] getColumnNames()
{
switch (GuiLanguage)
{
case Languages.LanguageEn:
return new string[] { "Code", "Name", "Contents" };
case Languages.LanguageFr:
return new string[] { "Code", "Nom", "Contenu" };
}
return null;
}
protected override object[] getItems()
{
return new object[] { Code, Name, Contents };
}
protected override void copyFrom(NeuronClientBase pSource)
{
base.copyFrom(pSource);
CompleteConfiguration theSource = pSource as CompleteConfiguration;
if (theSource == null)
{
throw new ArgumentException(WrongArgumentType, "pSource");
}
Code = theSource.Code;
Name = theSource.Name;
Contents = theSource.Contents;
IsVisible = theSource.IsVisible;
}
#endregion
#region Properties from main table.
[DataMember]
public string Code
{
[DebuggerStepThrough]
get { return mCode; }
[DebuggerStepThrough]
set
{
if (mCode != value)
{
mCode = value;
NotifyOfPropertyChange("Code");
}
}
}
[DataMember]
public string Name
{
[DebuggerStepThrough]
get { return mName; }
[DebuggerStepThrough]
set
{
if (mName != value)
{
mName = value;
NotifyOfPropertyChange("Name");
}
}
}
[DataMember]
public string Contents
{
[DebuggerStepThrough]
get { return mContents; }
[DebuggerStepThrough]
set
{
if (mContents != value)
{
mContents = value;
NotifyOfPropertyChange("Contents");
}
}
}
[DataMember]
public bool IsVisible
{
[DebuggerStepThrough]
get { return mIsVisible; }
[DebuggerStepThrough]
set
{
if (mIsVisible != value)
{
mIsVisible = value;
NotifyOfPropertyChange("IsVisible");
}
}
}
#endregion
#region Private fields.
private string mCode;
private string mName;
private string mContents;
private bool mIsVisible;
#endregion
}
[DataContract]
public class ColumnDescriptor
{
[DataMember]
public string ColumnName { get; set; }
[DataMember]
public ColumnAlignment TextAlignment { get; set; }
[DataMember]
public AgregationFunction Agregation { get; set; }
[DataMember]
public int GroupingPosition { get; set; }
[DataMember]
public string Format { get; set; }
}
[DataContract]
public class ListElements
{
public ListElements()
{
ElementGuid = Guid.Empty;
ElementCells = null;
IsSelected = false;
}
[DataMember]
public Guid ElementGuid { get; set; }
[DataMember]
public object[] ElementCells { get; set; }
public bool IsSelected { get; set; }
}
public enum ListContext
{
PatientExams, ToBeBilledExamsPublic, NotTransmittedClaimsPublic, TransmittedClaimsPublic, PaidClaimsPublic, InErrorClaimsPublic, ToBeBilledExamsPrivate, NotTransmittedClaimsPrivate, TransmittedClaimsPrivate,
PaidClaimsPrivate, InErrorClaimsPrivate, NmbListContexts
}
public enum AgregationFunction
{
None, Average, MinValue, MaxValue, FirstValue, LastValue, Count, Sum, NmbAgregationFunction
}
public enum ColumnAlignment
{
Left, Right, Center
}
}
<telerik:RadToolBar Grid.Row="0" Grid.Column="0" FocusManager.IsFocusScope="False" ItemsSource="{TemplateBinding local:TBaseReadsWn.ExtToolbarButtons}" ItemTemplate="{StaticResource dtToolbarButton}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" HorizontalContentAlignment="Left" VerticalContentAlignment="Center" Padding="30 4 0 4" > </telerik:RadToolBar><DataTemplate x:Key="dtToolbarButton" DataType="UICommandItem"> <Button Command="{Binding Command}" CommandParameter="{Binding CommandParameter}" Margin="{Binding Margins}" IsEnabled ="{Binding IsEnabled}" ToolTip="{Binding ToolTip}" Width = "22" Height= "20"> <Button.Content> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"></ColumnDefinition> <ColumnDefinition Width="Auto"></ColumnDefinition> </Grid.ColumnDefinitions> <Image Grid.Row="0" Grid.Column="0" Name="img" Style="{StaticResource stlImgBtnIm}" Source="{Binding Image}"></Image> <TextBlock Grid.Row="0" Grid.Column="1" Style="{StaticResource stlImgBtnTb}" Text="{Binding Text}"></TextBlock> </Grid> </Button.Content> </Button> <DataTemplate.Triggers> <DataTrigger Binding="{Binding Image}" Value="{x:Null}"> <DataTrigger.Setters> <Setter TargetName="img" Property="Visibility" Value="Collapsed"></Setter> </DataTrigger.Setters> </DataTrigger> <DataTrigger Binding="{Binding Margins}" Value="0"> <DataTrigger.Setters> <Setter Property="Margin" Value="2 2 2 2"></Setter> </DataTrigger.Setters> </DataTrigger> </DataTemplate.Triggers> </DataTemplate>
<Window x:Class="TestTreeListView.MainWindow" xmlns:local="clr-namespace:TestTreeListView" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase" Name="mainWindow" Title="MainWindow" Height="350" Width="525"> <Window.CommandBindings> <CommandBinding Command="local:MainWindow.AddParentRow" Executed="AddParentRow_Executed" /> </Window.CommandBindings> <Window.Resources> <!-- The style of the expand button in the totally rad tree. --> <Style x:Key="ExpandButtonStyle" TargetType="{x:Type telerik:GridViewToggleButton}"> <Setter Property="PresentationMode" Value="PlusMinus"/> </Style> <!-- Context menu for adding a child row to a parent row. --> <ContextMenu x:Key="ParentRowContextMenu"> <ContextMenu.CommandBindings> <CommandBinding Command="local:MainWindow.AddChildRow" Executed="AddChildRow_Executed" /> </ContextMenu.CommandBindings> <MenuItem Command="local:MainWindow.AddChildRow" /> </ContextMenu> <!-- A sorted view of the totally rad tree items. --> <CollectionViewSource x:Key="TotallyRadItemsView" Source="{Binding ElementName=mainWindow, Path=ParentItems}"> <CollectionViewSource.SortDescriptions> <scm:SortDescription PropertyName="Name" /> </CollectionViewSource.SortDescriptions> </CollectionViewSource> </Window.Resources> <Grid> <telerik:RadTreeListView Name="totallyRadTreeListView" AutoGenerateColumns="True" GridLinesVisibility="None" RowIndicatorVisibility="Collapsed" IsFilteringAllowed="False" CanUserSortColumns="False" HierarchyExpandButtonStyle="{StaticResource ExpandButtonStyle}" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ItemsSource="{Binding Source={StaticResource TotallyRadItemsView}}"> <telerik:RadTreeListView.ChildTableDefinitions> <telerik:TreeListViewTableDefinition ItemsSource="{Binding ChildItems}" /> </telerik:RadTreeListView.ChildTableDefinitions> <telerik:RadTreeListView.ContextMenu> <!-- Context menu for adding a parent row. --> <ContextMenu> <MenuItem Command="local:MainWindow.AddParentRow" CommandTarget="{Binding Path=PlacementTarget, RelativeSource={RelativeSource AncestorType={x:Type ContextMenu}}}" /> </ContextMenu> </telerik:RadTreeListView.ContextMenu> </telerik:RadTreeListView> </Grid></Window>using System;using System.Collections.Generic;using System.Collections.ObjectModel;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 Telerik.Windows.Controls.GridView; // for RowLoadedEventArgsusing Telerik.Windows.Controls.TreeListView; // for TreeListViewRownamespace TestTreeListView{ /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); // RadTreeListView doesn't select its items on right-click, so add // an event handler that accomplishes this. mTreeItemClickHandler = new MouseButtonEventHandler( TotallyRadTreeListViewRow_MouseRightButtonDown ); totallyRadTreeListView.RowLoaded += new EventHandler<RowLoadedEventArgs>( TotallyRadTreeListView_RowLoaded ); totallyRadTreeListView.RowUnloaded += new EventHandler<RowUnloadedEventArgs>( TotallyRadTreeListView_RowUnloaded ); } static MainWindow() { AddParentRow = new RoutedUICommand( "Add Parent Row", "AddParentRow", typeof( MainWindow ) ); AddChildRow = new RoutedUICommand( "Add Child Row", "AddChildRow", typeof( MainWindow ) ); } public static RoutedUICommand AddParentRow { get; set; } public static RoutedUICommand AddChildRow { get; set; } public ObservableCollection<ParentItem> ParentItems { get { return mParentItems; } } private void TotallyRadTreeListViewRow_MouseRightButtonDown( object sender, MouseButtonEventArgs e ) { TreeListViewRow row = sender as TreeListViewRow; row.IsSelected = true; // Throws an exception when right-clicking a child row. if ( row.ParentRow != null ) { // use row.ParentRow.Item here } // Show the context menu whenever a parent row is clicked. if ( row.Item is ParentItem ) { ContextMenu menu = FindResource( "ParentRowContextMenu" ) as ContextMenu; menu.IsOpen = true; } } private void TotallyRadTreeListView_RowLoaded( object sender, RowLoadedEventArgs e ) { if ( e.Row.Item != null ) { e.Row.MouseRightButtonDown += mTreeItemClickHandler; } } private void TotallyRadTreeListView_RowUnloaded( object sender, RowUnloadedEventArgs e ) { e.Row.MouseRightButtonDown -= mTreeItemClickHandler; } private void AddParentRow_Executed( object target, ExecutedRoutedEventArgs e ) { mParentItems.Add( new ParentItem() ); } private void AddChildRow_Executed( object target, ExecutedRoutedEventArgs e ) { ParentItem parentItem = totallyRadTreeListView.SelectedItem as ParentItem; parentItem.ChildItems.Add( new ChildItem() ); } private MouseButtonEventHandler mTreeItemClickHandler = null; ObservableCollection<ParentItem> mParentItems = new ObservableCollection<ParentItem>(); } public class ParentItem { public string Name { get { return name; } } public ObservableCollection<ChildItem> ChildItems { get { return mChildItems; } } private string name = "Parent" + i++; ObservableCollection<ChildItem> mChildItems = new ObservableCollection<ChildItem>(); private static int i = 0; } public class ChildItem { public string Name { get { return name; } } //public ObservableCollection<ChildItem> ChildItems { get { return mChildItems; } } private string name = "Child" + i++; //ObservableCollection<ChildItem> mChildItems = new ObservableCollection<ChildItem>(); private static int i = 0; }}