Telerik Forums
UI for WPF Forum
2 answers
979 views

Hi, I am building an application where I need to represent some hierarchical data in a tree. The standard WPF tree fell short on many fronts. So I am doing a trial of your WPF controls.

 

One of the big issues with the standard tree was that it was not (easily) possible to select an item within the tree from outside the tree. I was looking at your documentation, and it clearly shows that you can indeed use the SelectedItem property on your RadTreeView to set the selected item in the tree.

 

So I have implemented your tree and am trying to use that property to set the item, but I cannot get it to work. I have tried both through declarative binding and by setting the property programmatically, and in either case the RadTreeView does not set the correct item on the tree. It simply does nothing.

 

What am I doing wrong? If I can get that feature working with your RadTreeView, along with proper node Double-clicking, we will be purchasing at least developer licenses of the WPF RadControls.

Here is the TreeView code I am doing declaratively:

<t:RadTreeView Grid.Column="0" Grid.Row="2"
        MinHeight="100" MinWidth="100"
        DataContext="{Binding Source={x:Static SizingApp:ProjectManager.Instance}}"
        SelectedItem="{Binding CurrentSelected}">
    <t:RadTreeView.Resources>
        <Style TargetType="{x:Type t:RadTreeViewItem}">
            <Setter Property="IsExpanded" Value="True" />
        </Style>
        <HierarchicalDataTemplate x:Key="LoadTemplate">
            <Grid>
                <TextBlock Text="{Binding Name}">
                    <TextBlock.ContextMenu>
                        <ContextMenu DataContext="{Binding PlacementTarget.DataContext, RelativeSource={RelativeSource Self}}">
                            <MenuItem InputGestureText="{Resx ResxName=PSSPECApplication.Controls.ProjectControlResources,Key=load_ContextMenu_Edit_InputGestureText}"
                                      Click="MenuItem_EditLoadClick">
                                <MenuItem.Header>
                                    <TextBlock Text="{Binding Path=Name,
                                            StringFormat={Resx ResxName=PSSPECApplication.Controls.ProjectControlResources,Key=load_ContextMenu_Edit_Header},
                                            Mode=OneWay}" />
                                </MenuItem.Header>
                            </MenuItem>
                            <MenuItem Click="MenuItem_SaveLoadClick">
                                <MenuItem.Header>
                                    <TextBlock Text="{Binding Path=Name,
                                            StringFormat={Resx ResxName=PSSPECApplication.Controls.ProjectControlResources,Key=load_ContextMenu_Save_Header},
                                            Mode=OneWay}" />
                                </MenuItem.Header>
                            </MenuItem>
                            <MenuItem Header="{Resx ResxName=PSSPECApplication.Controls.ProjectControlResources, Key=load_ContextMenu_SaveAs_Header}"
                                      Click="MenuItem_SaveAsLoadClick" />
                            <MenuItem InputGestureText="{Resx ResxName=PSSPECApplication.Controls.ProjectControlResources,Key=load_ContextMenu_Delete_InputGestureText}"
                                      Click="MenuItem_RemoveClick">
                                <MenuItem.Header>
                                    <TextBlock Text="{Binding Path=Name,
                                            StringFormat={Resx ResxName=PSSPECApplication.Controls.ProjectControlResources,Key=load_ContextMenu_Delete_Header},
                                            Mode=OneWay}" />
                                </MenuItem.Header>
                            </MenuItem>
                            <MenuItem Header="{Resx ResxName=PSSPECApplication.Controls.ProjectControlResources,Key=load_ContextMenu_Copy_Header}"
                                    InputGestureText="{Resx ResxName=PSSPECApplication.Controls.ProjectControlResources,Key=load_ContextMenu_Copy_InputGestureText}"
                                    Click="MenuItem_CopyLoadClick" />
                        </ContextMenu>
                    </TextBlock.ContextMenu>
                </TextBlock>
            </Grid>
        </HierarchicalDataTemplate>
        <HierarchicalDataTemplate x:Key="StepTemplate"
                ItemsSource="{Binding Loads}"
                ItemTemplate="{StaticResource LoadTemplate}">
            <Grid>
                <TextBlock Text="{Binding Name}">
                    <TextBlock.ContextMenu>
                        <ContextMenu DataContext="{Binding PlacementTarget.DataContext, RelativeSource={RelativeSource Self}}">
                            <MenuItem InputGestureText="{Resx ResxName=PSSPECApplication.Controls.ProjectControlResources, Key=step_ContextMenu_Edit_InputGestureText}"
                                      Click="MenuItem_EditStepClick">
                                <MenuItem.Header>
                                    <TextBlock Text="{Binding Path=Name,
                                            StringFormat={Resx ResxName=PSSPECApplication.Controls.ProjectControlResources, Key=step_ContextMenu_Edit_Header},
                                            Mode=OneWay}" />
                                </MenuItem.Header>
                            </MenuItem>
                            <MenuItem Click="MenuItem_SaveStepClick">
                                <MenuItem.Header>
                                    <TextBlock Text="{Binding Path=Name,
                                            StringFormat={Resx ResxName=PSSPECApplication.Controls.ProjectControlResources, Key=step_ContextMenu_Save_Header},
                                            Mode=OneWay}" />
                                </MenuItem.Header>
                            </MenuItem>
                            <MenuItem Header="{Resx ResxName=PSSPECApplication.Controls.ProjectControlResources, Key=step_ContextMenu_SaveAs_Header}"
                                      Click="MenuItem_SaveAsStepClick" />
                            <MenuItem InputGestureText="{Resx ResxName=PSSPECApplication.Controls.ProjectControlResources, Key=step_ContextMenu_Delete_InputGestureText}"
                                      Click="MenuItem_RemoveClick">
                                <MenuItem.Header>
                                    <TextBlock Text="{Binding Path=Name,
                                            StringFormat={Resx ResxName=PSSPECApplication.Controls.ProjectControlResources, Key=step_ContextMenu_Delete_Header},
                                            Mode=OneWay}" />
                                </MenuItem.Header>
                            </MenuItem>
                            <MenuItem Header="{Resx ResxName=PSSPECApplication.Controls.ProjectControlResources, Key=step_ContextMenu_Copy_Header}"
                                    InputGestureText="{Resx ResxName=PSSPECApplication.Controls.ProjectControlResources, Key=step_ContextMenu_Copy_InputGestureText}"
                                    Click="MenuItem_CopyStepClick"/>
                            <MenuItem InputGestureText="{Resx ResxName=PSSPECApplication.Controls.ProjectControlResources, Key=step_ContextMenu_Paste_InputGestureText}"
                                    IsEnabled="{Binding IsLoadCopied, Source={x:Static SizingApp:ProjectManager.Instance}}"
                                    Click="MenuItem_PasteLoadClick">
                                <MenuItem.Header>
                                    <TextBlock Text="{Binding CurrentCopiedLoad,
                                            StringFormat={Resx ResxName=PSSPECApplication.Controls.ProjectControlResources, Key=step_ContextMenu_Paste_Header},
                                            Converter={StaticResource NameConverter},
                                            Source={x:Static SizingApp:ProjectManager.Instance},
                                            Mode=OneWay}" />
                                </MenuItem.Header>
                            </MenuItem>
                            <MenuItem Header="{Resx ResxName=PSSPECApplication.Controls.ProjectControlResources, Key=step_ContextMenu_Import_Load_Header}"
                                    Click="MenuItem_OpenLoadClick"/>
                            <MenuItem Header="{Resx ResxName=PSSPECApplication.Controls.ProjectControlResources, Key=step_ContextMenu_Add_Load_Header}"
                                    ItemsSource="{StaticResource mnuLoadSubmenuCommon}" MenuItem.Click="StepMenuItem_AddLoadClick"/>
                        </ContextMenu>
                    </TextBlock.ContextMenu>
                </TextBlock>
            </Grid>
        </HierarchicalDataTemplate>
        <HierarchicalDataTemplate x:Key="ProjectTemplate"
                ItemsSource="{Binding Steps}"
                ItemTemplate="{StaticResource StepTemplate}">
            <Grid>
                <TextBlock Text="{Binding Name}">
                    <TextBlock.ContextMenu>
                        <ContextMenu DataContext="{Binding PlacementTarget.DataContext, RelativeSource={RelativeSource Self}}">
                            <MenuItem InputGestureText="{Resx ResxName=PSSPECApplication.Controls.ProjectControlResources,Key=project_ContextMenu_Edit_InputGestureText}"
                                      Click="MenuItem_EditProjectClick"
                                      DataContext="{Binding DataContext, RelativeSource={RelativeSource AncestorType={x:Type ContextMenu}}}">
                                <MenuItem.Header>
                                    <TextBlock Text="{Binding Path=Name,
                                            StringFormat={Resx ResxName=PSSPECApplication.Controls.ProjectControlResources, Key=project_ContextMenu_Edit_Header},
                                            Mode=OneWay}" />
                                </MenuItem.Header>
                            </MenuItem>
                            <MenuItem Click="MenuItem_SaveProjectClick">
                                <MenuItem.Header>
                                    <TextBlock Text="{Binding Path=Name,
                                            StringFormat={Resx ResxName=PSSPECApplication.Controls.ProjectControlResources, Key=project_ContextMenu_Save_Header},
                                            Mode=OneWay}" />
                                </MenuItem.Header>
                            </MenuItem>
                            <MenuItem Header="{Resx ResxName=PSSPECApplication.Controls.ProjectControlResources, Key=project_ContextMenu_SaveAs_Header}"
                                      Click="MenuItem_SaveAsProjectClick"/>
                            <MenuItem InputGestureText="{Resx ResxName=PSSPECApplication.Controls.ProjectControlResources, Key=project_ContextMenu_Delete_InputGestureText}"
                                      Click="MenuItem_RemoveClick">
                                <MenuItem.Header>
                                    <TextBlock Text="{Binding Path=Name,
                                            StringFormat={Resx ResxName=PSSPECApplication.Controls.ProjectControlResources, Key=project_ContextMenu_Delete_Header},
                                            Mode=OneWay}" />
                                </MenuItem.Header>
                            </MenuItem>
                            <MenuItem Header="{Resx ResxName=PSSPECApplication.Controls.ProjectControlResources, Key=project_ContextMenu_Copy_Header}"
                                    InputGestureText="{Resx ResxName=PSSPECApplication.Controls.ProjectControlResources, Key=project_ContextMenu_Copy_InputGestureText}"
                                    Click="MenuItem_CopyProjectClick" />
                            <MenuItem InputGestureText="{Resx ResxName=PSSPECApplication.Controls.ProjectControlResources, Key=project_ContextMenu_Paste_InputGestureText}"
                                    IsEnabled="{Binding IsStepCopied, Source={x:Static SizingApp:ProjectManager.Instance}}"
                                    Click="MenuItem_PasteStepClick">
                                <MenuItem.Header>
                                    <TextBlock Text="{Binding CurrentCopiedStep,
                                            StringFormat={Resx ResxName=PSSPECApplication.Controls.ProjectControlResources, Key=project_ContextMenu_Paste_Header},
                                            Converter={StaticResource NameConverter},
                                            Source={x:Static SizingApp:ProjectManager.Instance},
                                            Mode=OneWay}" />
                                </MenuItem.Header>
                            </MenuItem>
                            <MenuItem Header="{Resx ResxName=PSSPECApplication.Controls.ProjectControlResources, Key=projectTree_Project_ImportStep_Header}"
                                    Click="MenuItem_OpenStepClick" />
                            <MenuItem Header="{Resx ResxName=PSSPECApplication.Controls.ProjectControlResources, Key=projectTree_Project_AddStep_Header}"
                                    Click="MenuItem_AddStepsClick"/>
                        </ContextMenu>
                    </TextBlock.ContextMenu>
                </TextBlock>
            </Grid>
        </HierarchicalDataTemplate>
    </t:RadTreeView.Resources>
    <t:RadTreeViewItem Header="{Resx ResxName=PSSPECApplication.Controls.ProjectControlResources, Key=projectTree_Header}"
            ItemsSource="{Binding Projects}"
            IsExpanded="True"
            ItemTemplate="{StaticResource ProjectTemplate}">
        <t:RadTreeViewItem.ContextMenu>
            <ContextMenu DataContext="{Binding PlacementTarget.DataContext, RelativeSource={RelativeSource Self}}">
                <MenuItem Header="{Resx ResxName=PSSPECApplication.Controls.ProjectControlResources, Key=projectTree_NewProject_Header}"
                        Icon="{Resx ResxName=PSSPECApplication.Controls.ProjectControlResources, Key=addProject_Image_Small}"
                        Click="NewProject_Click"/>
                <MenuItem Header="{Resx ResxName=PSSPECApplication.Controls.ProjectControlResources, Key=projectTree_OpenProject_Header}"
                        Icon="{Resx ResxName=PSSPECApplication.Controls.ProjectControlResources, Key=openProject_Image_Small}"
                        Click="OpenProject_Click"/>
                <MenuItem Header="{Resx ResxName=PSSPECApplication.Controls.ProjectControlResources, Key=projectTree_SaveAll_Header}"
                        InputGestureText="{Resx ResxName=PSSPECApplication.Controls.ProjectControlResources, Key=projectTree_SaveAll_InputGestureText}"
                        Click="SaveAllProjects_Click"/>
                <MenuItem InputGestureText="{Resx ResxName=PSSPECApplication.Controls.ProjectControlResources, Key=projectTree_Paste_InputGestureText}"
                        IsEnabled="{Binding IsProjectCopied, Source={x:Static SizingApp:ProjectManager.Instance}}"
                        Click="MenuItem_PasteProjectClick">
                    <MenuItem.Header>
                        <TextBlock Text="{Binding CurrentCopiedProject,
                                StringFormat={Resx ResxName=PSSPECApplication.Controls.ProjectControlResources, Key=projectTree_Paste_Header},
                                Converter={StaticResource NameConverter},
                                Source={x:Static SizingApp:ProjectManager.Instance},
                                Mode=OneWay}" />
                    </MenuItem.Header>
                </MenuItem>
            </ContextMenu>
        </t:RadTreeViewItem.ContextMenu>
    </t:RadTreeViewItem>
</t:RadTreeView>

Now the Projects property that the first node ItemsSource is bound to works just fine. However, the SelectedItem property on the TreeView itself seems to do nothing. Both the Projects property and the CurrentSelected property are both DependencyProperties. Both have call back event handlers that fire off INotifyPropertyChanged PropertyChanged event handlers indicating the properties have changed. I have other controls on the application that are bound to CurrentSelected and they change along with CurrentSelected just fine.

So why doesn't the RadTreeView also?

Alex Fidanov
Telerik team
 answered on 11 Oct 2010
1 answer
155 views
Hi,

Having a Radbutton

<telerik:RadButton Width="150"  Click="RadButton_Click" Content="Save insert/edit" Margin="0,0,5,0" x:Name="btnSave"
Command="telerikGrid:RadGridViewCommands.CommitEdit" CommandTarget="{Binding ElementName=radGridPhases}" />

I have exsperienced that the click event does not get called, is this correct behavior?.

I want to also update my database, when I click this button. How can I run some exstra code, when clicking this button.

Best regards

Ole
Milan
Telerik team
 answered on 11 Oct 2010
7 answers
208 views
Hi everybody,

the clipboard functionality of the RadGridView is exactly what I need to exchange data with excel. But we also have the requirement to provide the data in additional application specific format. Is there a way to use the standard clipboard functionality for text format and combine it with own functions to provide the data in an application specific format?

Regards Uli
Yavor Georgiev
Telerik team
 answered on 11 Oct 2010
4 answers
76 views
Hi,
I'm brand new to Telerik and I'm feeling kind of stupid.
I have a 2D Stacked Bar Chart

I am trying to refresh the data after a set interval.  I'm creating a dashboard application.
Whenever I refresh the data the new data is just getting added to the old data.
I tried setting the itemsource to nothing but it does not seem to make any difference.

The code I'm using was basically cannibalized from one of the demos and I really don't know what I'm doing.

First off how do I remove the data before adding it again?

Second is there a good place someone can point me to, to learn more about the following objects?
SeriesMapping, DataSeries, ItemMapping, DataPointMember.... I'm having a hard time understanding when to use what.

Thanks in advance and I apologize for my ignorance.
Tim
Vladimir Milev
Telerik team
 answered on 11 Oct 2010
1 answer
154 views
Hi,
I have address types combobox in my RadGridView.
 <telerik:GridViewComboBoxColumn Header="Address Type" Width="100"  Name="AddressTypes" SelectedValueMemberPath="AddressTypeID" DataMemberBinding="{Binding AddressTypeID ,Mode=TwoWay}" DisplayMemberPath="Name"  />

How can I make is eidtable and text complte property etc like in regular combox.
Thanks
Maya
Telerik team
 answered on 11 Oct 2010
5 answers
761 views
Hi
I have a GridView that shows a bunch of rows and has 15 columns, let me name them A1, A2, A3, M1, M2, ...to M12.
Each "M" column can have a value that is either "1" or "0".
I want to show the cell that are "1" with background="Black" and those that are "0" with Background="White".

Following the documentation  I use a class CellTemplateSelector that implement a DataTemplateSelector ( object item, DependencyObject container ).

In the documentation the Template selector is used for formatting one column of the GridView based in its value.So it works for one column in the whole row.

In my case I need to call my CelllTemplateSelector from every "M" column cell in the row and decide what format apply to the cell based on its value (0 or 1).

If I use the Selector implemented in the documentation, I notice that when I call it, I get the parameter "item" that gives me the whole row but I don't know what column I am calling from.

I need to get the column from where I am calling from in order to check for the value of that specific column in order to select the template to apply.

So my question is: How should I call my TemplateSelector and pass the row but also the column name I am calling from.. 

Thanks
Willy Vidable
Top achievements
Rank 1
 answered on 08 Oct 2010
3 answers
126 views
Hi there,

I have a RadChart plotting actual and forecast sales against month using a single LineSeriesDefinition.  I would like to change the colour of the forecasted sales numbers, after the current month.  Is that possible?

Many thanks!

Anthony
Velin
Telerik team
 answered on 08 Oct 2010
1 answer
175 views

After the user clicks and resizes a rad splitter in a docking layout, the splitter is left with keyboard focus.  This is not the case with standard WPF grid splitters and I would like to have a similar behavior in a docking layout. To test: Click and resize a splitter then press the up/dn/left/right arrow keys -- I would like keyboard focus left where it used to be not on the splitter.

Usually in WPF, this means setting Focusable = false. I am setting that on the RadSplitContainers and on RadDocking but it does not help.

Does anyone have a technique for acheiving this?

John
John Schroedl
Top achievements
Rank 2
 answered on 08 Oct 2010
1 answer
43 views
Hello,

is it possible to overwrite the "Grouped by" text in the groupdescriptor header?
I've found no attribute for changing the text.
Vanya Pavlova
Telerik team
 answered on 08 Oct 2010
6 answers
811 views
I have a simple 3 column GridView.  The 2nd column is defined as a GridViewComboBoxColumn.  I would like to bind an Enum list to that ComboBox.ItemsSource property.  How do I do this?

On a typical combobox, I could do the following:

 

 

 

cboValueType.ItemsSource = Enum.GetValues(ValueType); 

Thanks for your help.

 

 

 

 

 

 

 

 

Barnabas
Top achievements
Rank 1
 answered on 08 Oct 2010
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?