Telerik Forums
UI for WPF Forum
5 answers
239 views
I am finding that the content of the RadDataForm control (using the Metro theme) is small. When I say "the content" I mean the fields within the RadDataForm control.

When the basic layout is used, all controls are the same size. If I add for example FontSize="16" to the RadDataForm control, I get different sizes in the rendered controls. For example:

* The DateTime field is 6 pixels taller than the ComboBox
* The regular TextBox field is 3 pixels taller than the ComboBox

Also, the RadDataForm header seems to get bolded when the font size is increased. Finally, is there a way to establish the space between the labels (on the left) and the controls (on the right)?

Thanks in advance, Marcelo.
Vanya Pavlova
Telerik team
 answered on 23 Aug 2011
1 answer
167 views
Hello,

I need to be able to update a GridViewComboBoxColumn's ItemsSource when it drops down. How can I capture the drop down event of the GridViewComboBoxColumn? An example would be appreciated.

G

p.s. I am NOT using MVVM. I am binding the GridViewComboBoxColumn using ItemsSource of a List<int>.
Maya
Telerik team
 answered on 23 Aug 2011
1 answer
166 views
Hi,

We are using the wpf RadRichText control in our project.
We have a grid control and one of the column is the rich text control and since we added the control we facing
a memory problems our application memory continue grow and it seems that the control don't free up memory.
here is the code:
<telerikRTF:RtfDataProvider SetupDocument="RtfDataProvider_SetupDocument"
                                    Rtf="{Binding ElementName=rtfControl, Path=RichText,Mode= TwoWay}"
                                    UpdateSourceTrigger="PropertyChanged"
                                    RichTextBox="{Binding ElementName=rtfControlMain}"/>
 
        <telerik:RadRichTextBox x:Name="rtfControlMain"
                                ToolTip="{Binding ElementName=rtfControl,Path=Text,Mode=OneWay}"
                                IsReadOnly="{Binding ElementName=rtfControl,Path=IsReadOnly}"
                                FontFamily="Segoe UI" FontSize="11" DocumentInheritsDefaultStyleSettings="True" Grid.Row="2"  Loaded="rtfMain_Loaded">
            <telerik:RadRichTextBox.IsSelectionMiniToolBarEnabled>
                <MultiBinding Converter="{StaticResource booleanLogicalNORConverter}" >
                    <MultiBinding.Bindings>
                        <Binding ElementName="rtfControl" Path="IsReadOnly"/>
                        <Binding ElementName="rtfControl" Path="IsToolBarVisible"/>
                    </MultiBinding.Bindings>
                </MultiBinding>
            </telerik:RadRichTextBox.IsSelectionMiniToolBarEnabled>
            <telerik:RadRichTextBox.Resources>
                <Style TargetType="TextBlock" />
            </telerik:RadRichTextBox.Resources>
        </telerik:RadRichTextBox>
Iva Toteva
Telerik team
 answered on 23 Aug 2011
2 answers
105 views
Hello,

I have created a simple WPF app to demonstrate a bug we are seeing.

In our application, we have a RadPane that only certain users should be able to see because of Permissions.  We are attempting to do this using the Visibility property on the RadPane.

If I create a RadDocking control with a RadPaneGroup and set one of the RadPane elements Visibility property to Collapsed.  It does two things.

  1. It shows up when I unpin the Visible RadPane (note that if you unpin the Service Card Explorer, you suddenly see the Operations Explorer)
  2. If you try and repin the Pane, a Cannot call Arrange on a UIElement with infinite size or NaN. exception is thrown.

XAML

<Window x:Class="RadDockingPaneVisibilityBug.MainWindow"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <telerik:RadDocking Grid.Row="1">
            <telerik:RadDocking.DocumentHost>
                <telerik:RadSplitContainer>
                    <telerik:RadPaneGroup>
                        <telerik:RadDocumentPane Header="Content" Visibility="Collapsed" CanUserClose="False">
                            <TextBlock Text="Content" />
                        </telerik:RadDocumentPane>
                    </telerik:RadPaneGroup>
                </telerik:RadSplitContainer>
            </telerik:RadDocking.DocumentHost>
            <telerik:RadSplitContainer>
                <telerik:RadPaneGroup>
                    <telerik:RadPane Header="Service Card Explorer" CanUserClose="False">
                        <TextBlock Text="Service Card Explorer" />
                    </telerik:RadPane>
                    <telerik:RadPane Header="Operations Explorer" CanUserClose="False" Visibility="Collapsed">
                        <TextBlock Text="Operations Explorer" />
                    </telerik:RadPane>
                </telerik:RadPaneGroup>
            </telerik:RadSplitContainer>
        </telerik:RadDocking>
    </Grid>
</Window>


Steps to reproduce:

  1. Launch the application
  2. Unpin the 'Service Card Explorer' pane - note we suddenly see the Operations Explorer pane - this should not be
  3. Unpin the 'Operations Explorer' pane
  4. Try and pin the 'Service Card Explorer' pane - note the exception

Exception:

System.InvalidOperationException was unhandled
  Message=Cannot call Arrange on a UIElement with infinite size or NaN. Parent of type 'Telerik.Windows.Controls.Primitives.TabStripPanel' invokes the UIElement. Arrange called on element of type 'Telerik.Windows.Controls.RadPane'.
  Source=PresentationCore
  StackTrace:
       at System.Windows.UIElement.Arrange(Rect finalRect)
       at Telerik.Windows.Controls.Primitives.TabStripPanel.ArrangeOverride(Size finalSize)
       at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
       at System.Windows.UIElement.Arrange(Rect finalRect)
       at MS.Internal.Helper.ArrangeElementWithSingleChild(UIElement element, Size arrangeSize)
       at System.Windows.Controls.ItemsPresenter.ArrangeOverride(Size arrangeSize)
       at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
       at System.Windows.UIElement.Arrange(Rect finalRect)
       at System.Windows.Controls.Grid.ArrangeOverride(Size arrangeSize)
       at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
       at System.Windows.UIElement.Arrange(Rect finalRect)
       at System.Windows.Controls.Control.ArrangeOverride(Size arrangeBounds)
       at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
       at System.Windows.UIElement.Arrange(Rect finalRect)
       at System.Windows.Controls.DockPanel.ArrangeOverride(Size arrangeSize)
       at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
       at System.Windows.UIElement.Arrange(Rect finalRect)
       at System.Windows.Controls.Border.ArrangeOverride(Size finalSize)
       at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
       at System.Windows.UIElement.Arrange(Rect finalRect)
       at System.Windows.Controls.Grid.ArrangeOverride(Size arrangeSize)
       at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
       at System.Windows.UIElement.Arrange(Rect finalRect)
       at System.Windows.Controls.Control.ArrangeOverride(Size arrangeBounds)
       at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
       at System.Windows.UIElement.Arrange(Rect finalRect)
       at System.Windows.Controls.Grid.ArrangeOverride(Size arrangeSize)
       at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
       at System.Windows.UIElement.Arrange(Rect finalRect)
       at MS.Internal.Helper.ArrangeElementWithSingleChild(UIElement element, Size arrangeSize)
       at System.Windows.Controls.ContentPresenter.ArrangeOverride(Size arrangeSize)
       at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
       at System.Windows.UIElement.Arrange(Rect finalRect)
       at System.Windows.Documents.AdornerDecorator.ArrangeOverride(Size finalSize)
       at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
       at System.Windows.UIElement.Arrange(Rect finalRect)
       at System.Windows.Controls.Border.ArrangeOverride(Size finalSize)
       at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
       at System.Windows.UIElement.Arrange(Rect finalRect)
       at System.Windows.Window.ArrangeOverride(Size arrangeBounds)
       at System.Windows.FrameworkElement.ArrangeCore(Rect finalRect)
       at System.Windows.UIElement.Arrange(Rect finalRect)
       at System.Windows.ContextLayoutManager.UpdateLayout()
       at System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)
       at System.Windows.Media.MediaContext.InvokeOnRenderCallback.DoWork()
       at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
       at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
       at System.Windows.Media.MediaContext.AnimatedRenderMessageHandler(Object resizedCompositionTarget)
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
       at System.Windows.Threading.DispatcherOperation.InvokeImpl()
       at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
       at System.Threading.ExecutionContext.runTryCode(Object userData)
       at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Windows.Threading.DispatcherOperation.Invoke()
       at System.Windows.Threading.Dispatcher.ProcessQueue()
       at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
       at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
       at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
       at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
       at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
       at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
       at System.Windows.Threading.Dispatcher.Run()
       at System.Windows.Application.RunDispatcher(Object ignore)
       at System.Windows.Application.RunInternal(Window window)
       at System.Windows.Application.Run(Window window)
       at System.Windows.Application.Run()
       at RadDockingPaneVisibilityBug.App.Main() in C:\Data\Source\Work\2\Jerrys\ServiceCard\Main\Sandbox\RadDockingPaneVisibilityBug\RadDockingPaneVisibilityBug\obj\x86\Debug\App.g.cs:line 0
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException:

Rick Glos
Top achievements
Rank 1
 answered on 23 Aug 2011
1 answer
282 views
Hey all, I am attempting to generate a heatmap from data I am pulling from a database. Basically, I am pulling a list of how many visitors we have had at our properties by customer zipcode. In the class I wrote to handle the data retrieval, I also have a method for Geocoding the zipcodes into Latitude and Longitude. The problem I am having is partly due to a poor understanding of WPF, and partly due to never having used a Telerik control before now. My current XAML is as follows:
<Window x:Class="HeatMap.MainWindow"
                xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
                Title="MainWindow" Height="552" Width="497" Loaded="Window_Loaded" WindowStartupLocation="CenterScreen">
    <Grid>
        <telerik:RadMap Height="auto" HorizontalAlignment="Stretch" Name="radMap1" VerticalAlignment="Stretch" Width="auto"  >
            <telerik:RadMap.Provider>
                <telerik:BingMapProvider ApplicationId="API_KEY" Mode="Aerial" />
            </telerik:RadMap.Provider>
            <telerik:BingGeocodeProvider ApplicationId="API_KEY" GeocodeCompleted="BingGeocodeProvider_GeocodeCompleted" x:Name="Bing">
                <telerik:BingGeocodeProvider.MapControl>
                    <telerik:RadMap Visibility="Hidden" CommandBarVisibility="Hidden">
                        <telerik:RadMap.SpatialReference>
                            <telerik:SpatialReference AngularUnitOfMeasurement="0" Authority="{x:Null}" CentralMeridian="0" Datum="{x:Null}" DatumAuthority="{x:Null}" FalseEasting="0" FalseNorthing="0" GeoGcs="{x:Null}" LatitudeOfOrigin="0" MaxLatitude="0" MaxLongitude="0" MinLatitude="0" MinLongitude="0" OffsetX="0" OffsetY="0" Primem="0" PrimemAuthority="{x:Null}" ProjectionAuthority="{x:Null}" ScaleX="0" ScaleY="0" SpheroidAuthority="{x:Null}" SpheroidFlattening="0" SpheroidRadius="0" StandardParallel="0" UnitAuthority="{x:Null}" />
                        </telerik:RadMap.SpatialReference>
                    </telerik:RadMap>
                </telerik:BingGeocodeProvider.MapControl>
            </telerik:BingGeocodeProvider>
            <telerik:InformationLayer Name="dataLayer" >
                 
            </telerik:InformationLayer>
        </telerik:RadMap>
    </Grid>
</Window>

I have seen the code samples from the telerik demos, but most likely due to my lack of experience with WPF they haven't helped me much. What I would like to be able to do would be for every zip code create a point on the map in a color representing the number of visitors, and upon mouse hover (or even mouse click) I would like to show a tooltip showing the number of visitors and the zipcode.

Would anyone know of a good tutorial to help fill in the gaps in my knowledge so I can more easily accomplish my goal, or have any input to send me in the right direction? Thanks for the help all!
Andrey
Telerik team
 answered on 23 Aug 2011
1 answer
142 views
Hey there,

can anybody explain how to show the state and city names on the map when using the EmptyProvider?

I am not using the openstreetmap or bingprovider because I only want to show Asia on my map centered on the screen.
If I am using one of the providers above the map shows basically the entire earth and not only the shapes I have binded (Asia).

I am looking for a map that only shows Asia centered in the screen with its capital city names and states.

Thanks for any feedback.

Below you'll find my xaml....

 <telerik:RadMap x:Name="radMap" UseDefaultLayout="False">
            <telerik:RadMap.Providers>
                <telerik:EmptyProvider/>
                <!--<telerik:OpenStreetMapProvider/>-->
                <!--<telerik:BingMapProvider
                    ApplicationId="An5jY7yMdjU12_fZjI4evnJJ_Juwt38lr9TPdRK3UjaT2Uio-nKzl10K8jPnLnvT"
                    IsLabelVisible="True"/>-->
                
            </telerik:RadMap.Providers>

            <telerik:InformationLayer x:Name="shapeLayer" >
                <telerik:InformationLayer.Reader>
                    <telerik:MapShapeReader
                        DataSource="/DTClientServices.PlanningSuite.Views;component/Shapefiles/Asia/asia.dbf"
                        Source="/DTClientServices.PlanningSuite.Views;component/Shapefiles/Asia/asia.shp"/>
                </telerik:InformationLayer.Reader>
                <telerik:InformationLayer.ShapeFill>
                    <telerik:MapShapeFill Fill="#64D3D3D3" StrokeThickness="0"/>
                </telerik:InformationLayer.ShapeFill>
                <telerik:InformationLayer.HighlightFill>
                    <telerik:MapShapeFill Fill="#64FFC21C" StrokeThickness="0"/>
                </telerik:InformationLayer.HighlightFill>
                </telerik:InformationLayer>


                <telerik:InformationLayer x:Name="informationLayer" ItemsSource="{Binding MapData}" >
                    <telerik:InformationLayer.ItemTemplate>
                        <DataTemplate>
                            <Grid   telerik:MapLayer.BaseZoomLevel="{Binding BaseZoomLevel}"
                                    telerik:MapLayer.Location="{Binding Location}"
                                    telerik:MapLayer.ZoomRange="{Binding ZoomRange}">
                            <m:MapIconView Height="15" Width="15">
                                <ToolTipService.ToolTip>
                                    <ToolTip>

                                        <Grid>
                                            <Grid.RowDefinitions>
                                                <RowDefinition/>
                                                <RowDefinition/>
                                            </Grid.RowDefinitions>

                                            <StackPanel Grid.Row="0">
                                                <TextBlock Grid.Row="0" FontWeight="Bold" Text="{Binding Caption,FallbackValue=Caption}"/>

                                                <Grid Margin="4">
                                                    <Grid.RowDefinitions>
                                                        <RowDefinition />
                                                        <RowDefinition />
                                                        <RowDefinition />
                                                        <RowDefinition />
                                                        <RowDefinition />
                                                    </Grid.RowDefinitions>
                                                    <Grid.ColumnDefinitions>
                                                        <ColumnDefinition/>
                                                        <ColumnDefinition/>
                                                    </Grid.ColumnDefinitions>

                                                    <StackPanel Grid.Row="0" Grid.Column="0" Orientation="Horizontal">
                                                        <TextBlock Text="{Binding Measure1, FallbackValue=Measure1}"/>
                                                        <TextBlock Text=": "/>
                                                    </StackPanel>
                                                    <TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding Volume1, FallbackValue=Volume1}"/>

                                                    <StackPanel Grid.Row="1" Grid.Column="0"  Orientation="Horizontal">
                                                        <TextBlock Text="{Binding Measure2, FallbackValue=Measure2}"/>
                                                        <TextBlock Text=": "/>
                                                    </StackPanel>

                                                    <TextBlock Grid.Row="1" Grid.Column="1" Text="{Binding Volume2, FallbackValue=Volume2}"/>

                                                    <Line Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" Stretch="Fill" Stroke="LightGray" X2="1"/>

                                                    <TextBlock Grid.Row="3" Grid.Column="0">Rating:</TextBlock>
                                                    <Ellipse
                                                        Grid.Row="3"
                                                        Grid.Column="1"
                                                        Fill="Green"
                                                        Height="10"
                                                        Width="10" Margin="0,0,120,0" />
                                                    <TextBlock Grid.Row="4" Grid.Column="0">Status:</TextBlock>
                                                    <Ellipse
                                                        Grid.Row="4"
                                                        Grid.Column="1"
                                                        Fill="Red"
                                                        Height="10"
                                                        Width="10" Margin="0,0,120,0" />
                                                </Grid>
                                            </StackPanel>


                                        </Grid>
                                    </ToolTip>
                                </ToolTipService.ToolTip>
                            </m:MapIconView>
                                <!--<telerik:MapLayer.HotSpot>
                                <telerik:HotSpot X="0.5" Y="0.5" ElementName="PART_Ellipse" />
                            </telerik:MapLayer.HotSpot>
                                
                            <Ellipse x:Name="PART_Ellipse"
                               Width="20"
                               Height="20"
                               Stroke="Red"
                               StrokeThickness="3"
                               Fill="Transparent">
                                <ToolTipService.ToolTip>
                                    <ToolTip Content="{Binding Caption}" />
                                </ToolTipService.ToolTip>
                            </Ellipse>-->
                                
                                
                        </Grid>
                    </DataTemplate>
                </telerik:InformationLayer.ItemTemplate>
            </telerik:InformationLayer>
        </telerik:RadMap>
Andrey
Telerik team
 answered on 23 Aug 2011
3 answers
198 views

Hi,

I am having some problems with RadTreeView.ExpandItemByPath(...). It does not do anything when I call it.

I guess the problem is that  I did not set headers for the listviewitems, but when I try to set it with the commented setter, the name does not get displayed.

Below you can see the (stripped) XAML for my ListView:

<telerik:RadTreeView ItemsSource="{Binding Items}">
                            
               <telerik:RadTreeView.ItemContainerStyle>
                   <Style TargetType="telerik:RadTreeViewItem">
                       <!--<Setter Property="Header" Value="{Binding Path=Item, Converter={StaticResource ClientTreeItemToTextConverter}}"/>-->
                       <Setter Property="IsDropAllowed" Value="{Binding IsDropAllowed, Mode=TwoWay}"/>
                       <Setter Property="IsLoadOnDemandEnabled" Value="{Binding IsLoadOnDemandEnabled, Mode=TwoWay}"/>
                       <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
                       <Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
                    </Style>
               </telerik:RadTreeView.ItemContainerStyle>
 
               <telerik:RadTreeView.ItemTemplate>
                   <HierarchicalDataTemplate ItemsSource="{Binding Children}">
                       <StackPanel Orientation="Horizontal" Margin="2">
                           <Image Margin="0 0 4 0" Source="{Binding Path=Item.Type, Converter={StaticResource NodeTypeToImageConverter}}" VerticalAlignment="Center"/>
                           <TextBlock Text="{Binding Path=Item, Converter={StaticResource ClientTreeItemToTextConverter}}" VerticalAlignment="Center"/>
                       </StackPanel>
                   </HierarchicalDataTemplate>
               </telerik:RadTreeView.ItemTemplate>
 
          </telerik:RadTreeView>
Petar Mladenov
Telerik team
 answered on 23 Aug 2011
10 answers
445 views
Hi,

Could you please tell me what the best way to validating the form is? (and displaying error messages/highlighting fields)

Many thanks,
Daryl
Marcelo
Top achievements
Rank 1
 answered on 23 Aug 2011
11 answers
478 views

Hi

I posted that as a support ticket, but if you have an answer for me, feel frre to give it, thank you very much. I'll paste the answer form the support.


 

I am testing your product. I am trying to make a nested hierarchy inside a radGridView. My code is inspired from both the Getting started documentation and an example you gave about nested hierarchy. Please, see the attached project.

 

My goal is to show a list of Divisions in a gridView, each division has teams, and each team has some employees.

 

I have an Employee class:

 

    public class Employee

    {

        public string FirstName

        {

            get;

            set;

        }

        public string LastName

        {

            get;

            set;

        }

        public int Age

        {

            get;

            set;

        }

        public bool Married

        {

            get;

            set;

        }

 

    }

 

 

A team class who has a collection of employees:

 

public class Team

    {

        private ObservableCollection<Employee> _empl = new ObservableCollection<Employee>();

 

        public ObservableCollection<Employee> Empl

        {

            get

            { return _empl; }

 

            set

            { _empl = value; }

        }

 

 

        public int Ident

        {

            get;

            set;

        }

        public string Nom

        {

            get;

            set;

        }

        public int Place

        {

            get;

            set;

        }

 

    }

 

 

A division class who has a list of teams:

    public class Division

    {

        public int Id

        {

            get;

            set;

        }

        public string Name

        {

            get;

            set;

        }

        public List<Team> Teams

        {

            get;

            set;

        }

 

    }

 

And a DivisionService class, who creates a collection of divisions, populating each division with some teams and some teams with some employees. Here is an excerpt of the class:

 

   public class DivisionsService

    {

        public static ObservableCollection<Division> GetDivisions()

        {

ObservableCollection<Division> divisions = new ObservableCollection<Division>();

            Division dA = new Division();

            dA.Name = "Division A";

            dA.Id = 1;

            dA.Teams = new List<Team>();

            Team team1 = new Team();

            team1.Ident = 1;

            team1.Nom = "Team I";

            team1.Place = 1;

            Employee emp01 = new Employee();

            emp01.FirstName = "Maria";

            emp01.LastName = "Anders";

            emp01.Married = true;

            emp01.Age = 24;

            team1.Empl.Add(emp01);

            Employee emp02 = new Employee();

            emp02.FirstName = "Klodia";

            emp02.LastName = "Choufleur";

            emp02.Married = false;

            emp02.Age = 28;

            team1.Empl.Add(emp02);

            dA.Teams.Add(team1);

 

            Team team2 = new Team();

            team2.Ident = 2;

            team2.Nom = "Team II";

            team2.Place = 2;

            Employee emp03 = new Employee();

            emp03.FirstName = "Jean";

            emp03.LastName = "Bon";

            emp03.Married = true;

            emp03.Age = 44;

            team2.Empl.Add(emp03);

 

            dA.Teams.Add(team2);

 

          (code here)

           

           return divisions;

        }

    }

 

 

The XAML creates the gridview and the data template:

 

<Window x:Class="TestRadGridView.MainWindow"

                           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

                           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

                           xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"

                           Title="MainWindow" Height="350" Width="525">

             <Grid>

        <telerik:RadGridView x:Name="HierarchicalGridView"

                             AutoGenerateColumns="False"

                             MinHeight="386">

 

 

 

            <telerik:RadGridView.Columns>

                <telerik:GridViewDataColumn DataMemberBinding="{Binding Id}"

                                       Header="Id" />

                <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}"

                                       Header="Name" />

            </telerik:RadGridView.Columns>

 

            <telerik:RadGridView.HierarchyChildTemplate>

                <DataTemplate>

                    <telerik:RadGridView

                        Name="teamGrid"

                        ShowGroupPanel="False"

                        AutoGenerateColumns="False">

                        <telerik:RadGridView.Columns>

                            <telerik:GridViewDataColumn

                                Header="Id"

                                DataMemberBinding="{Binding Ident}"/>

                            <telerik:GridViewDataColumn

                                Header="Nom"

                                DataMemberBinding="{Binding Nom}"/>

                            <telerik:GridViewDataColumn

                                Header="Place"

                                DataMemberBinding="{Binding Place}"/>

                        </telerik:RadGridView.Columns>

                        <telerik:RadGridView.HierarchyChildTemplate>

                            <DataTemplate>

                                <telerik:RadGridView

                                    Name="employeesGrid"

                                    ShowGroupPanel="False">

                                </telerik:RadGridView>

                            </DataTemplate>

                        </telerik:RadGridView.HierarchyChildTemplate>

                    </telerik:RadGridView>

                </DataTemplate>

            </telerik:RadGridView.HierarchyChildTemplate>

 

        </telerik:RadGridView>    

    </Grid>

</Window>

 

 

And the code behind the data binding and the relations:

 

       public MainWindow()

        {

            InitializeComponent();

 

            GridViewTableDefinition TeamsTableDefinition = new GridViewTableDefinition();

            TeamsTableDefinition.Relation = new PropertyRelation("Teams");

            this.HierarchicalGridView.TableDefinition.ChildTableDefinitions.Add(TeamsTableDefinition);

 

            GridViewTableDefinition emplTableDefinition = new GridViewTableDefinition();

            emplTableDefinition.Relation = new PropertyRelation("empl");

            TeamsTableDefinition.ChildTableDefinitions.Add(emplTableDefinition);

 

 

            this.HierarchicalGridView.ItemsSource = DivisionsService.GetDivisions();

 

        }

 

 

So, it does not work: I see the divisions, but there are no teams (and of course I can’t see is there are employees in the teams).

 

If I delete, in the XAML code, the data template, things are a little better: I see Teams in the divisions, but I do not see Employees in teams. Anyway, I need the data template.

 

So, what I did wrong?

 

 

Could-you too, please, say how to access a selected item in a nested grid? Thank you again.

 

Cordially

 

Richard

Richard
Top achievements
Rank 1
 answered on 23 Aug 2011
4 answers
888 views
Hi, I am prototyping with radgridview and am not very wpf experienced. I have a simple problem I can't solve and am hoping someone can give me a hint.

<telerik:RadGridView x:Name="Navigation"
                    AutoGenerateColumns="False"
                    ItemsSource="{StaticResource data}"
                    >

"data" is an ObservableCollection and I was expecting the grid to update, when the collection gets updated. Data already in the list after initialisation is shown. I guessed this does not work, as its a StaticResource, but with DynamicResource it also does not work.

However if i use c# code it works:

this.Navigation.ItemsSource = this.data;

Now its obvious to me I am doing something wrong with the ItemsSource in xaml, but I just have no clue what I should be doing...
marc
Top achievements
Rank 1
 answered on 23 Aug 2011
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?