Hi, I have RadTreeView where the item can be added on various levels of the tree by clicking the button on the parent node. Sometimes when this parent has more children, the newly added item is not shown (the user needs to manually scroll to it, because it is below the other items). I need to automatically show the newly added item. I've tried everything but I couldn't get this to work. With the virtualization of the tree switched off I think that this code should work:
RadTreeViewItem seletedItem = treeView.ContainerFromItemRecursive(treeView.SelectedItem);
seletedItem.BringIntoView();
But it does not (nothing happens). Also I tried to call:
treeView.BringItemIntoView(seletedItem);
and
treeView.BringItemIntoView(reeView.SelectedItem);
with no success. Currently i am trying to use path (although I'm not sure this would work since I'm using ItemsTemplate for the items in the tree. Again with no success. Please tell me how to achieve the desired functionality - It does not need to be bound to selected item, I just need to be able to scroll automatically to (bring into view) to the desired item from the tree. Currently the code and XAML are the following:
<
HierarchicalDataTemplate
x:Key
=
"EquipmentTemplate"
DataType
=
"model:IComponentTreeItem"
ItemsSource
=
"{Binding Children}"
>
<
Grid
>
<
Grid.ColumnDefinitions
>
<
ColumnDefinition
Width
=
"*"
/>
<
ColumnDefinition
Width
=
"Auto"
/>
</
Grid.ColumnDefinitions
>
<
TextBox
HorizontalAlignment
=
"Stretch"
PreviewMouseDown
=
"UIElement_OnPreviewMouseDown"
IsReadOnly
=
"{Binding ViewSettings.IsReadOnly}"
Text
=
"{Binding Name, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnDataErrors=True, NotifyOnValidationError=True}"
/>
<
StackPanel
Orientation
=
"Horizontal"
Grid.Column
=
"1"
>
<
telerik:RadButton
HorizontalAlignment
=
"Right"
Content
=
"+"
Width
=
"20"
Height
=
"20"
Foreground
=
"{StaticResource scbComponent}"
Click
=
"AddButton_OnClick"
Visibility
=
"{Binding Converter={StaticResource EquipmentToVisibilityConverter}, ConverterParameter=add}"
Command
=
"{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=DataContext.AddEquipmentCommand}"
CommandParameter
=
"{Binding}"
ToolTip
=
"New Component"
/>
<
telerik:RadButton
HorizontalAlignment
=
"Right"
Content
=
"X"
Width
=
"20"
Height
=
"20"
Foreground
=
"Red"
Visibility
=
"{Binding Converter={StaticResource EquipmentToVisibilityConverter}, ConverterParameter=delete}"
Command
=
"{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=DataContext.DeleteCommand}"
CommandParameter
=
"{Binding}"
/>
</
StackPanel
>
</
Grid
>
<
HierarchicalDataTemplate.ItemContainerStyle
>
<
Style
TargetType
=
"telerik:RadTreeViewItem"
>
<
Setter
Property
=
"HorizontalContentAlignment"
Value
=
"Stretch"
/>
<
Setter
Property
=
"IsExpanded"
Value
=
"{Binding IsExpanded, Mode=TwoWay}"
/>
</
Style
>
</
HierarchicalDataTemplate.ItemContainerStyle
>
</
HierarchicalDataTemplate
>
<
telerik:RadTreeView
Grid.Row
=
"0"
Grid.Column
=
"2"
IsVirtualizing
=
"False"
IsLineEnabled
=
"True"
MinWidth
=
"300"
x:Name
=
"ComponentsTree"
HorizontalContentAlignment
=
"Stretch"
HorizontalAlignment
=
"Stretch"
ItemTemplate
=
"{StaticResource EquipmentTemplate}"
IsEditable
=
"True"
AutoScrollToSelectedItem
=
"True"
SelectedItem
=
"{Binding SelectedTreeEquipment, Mode=TwoWay}"
ItemsSource
=
"{Binding Equipments}"
>
</
telerik:RadTreeView
>
private
void
AddButton_OnClick(
object
sender, RoutedEventArgs e)
{
var frameworkElement = sender
as
FrameworkElement;
if
(frameworkElement !=
null
)
{
var treeItem = frameworkElement.DataContext
as
IComponentTreeItem;
if
(treeItem ==
null
)
return
;
var tree = frameworkElement.GetVisualParent<RadTreeView>();
tree.BringIntoViewMode = BringIntoViewMode.HeaderAndItems;
tree.AutoScrollToSelectedItem =
false
;
var itemToScroll = (treeItem.Children !=
null
&& treeItem.Children.Any()) ? treeItem.Children.Last() : treeItem;
var path = GetPathFromIComponentTreeItem(itemToScroll);
tree.SelectItemByPath(path);
tree.BringPathIntoView(path);
}
}
public
string
GetPathFromIComponentTreeItem(IComponentTreeItem item)
{
string
path = item.Name;
IComponentTreeItem nextParent = item.ParentItem;
while
(nextParent !=
null
)
{
path = String.Concat(nextParent.Name, @
"\"
, path);
nextParent = nextParent.ParentItem;
}
return
path;
}
public
interface
IComponentTreeItem
{
string
Name {
get
;
set
; }
short
Order {
get
;
set
; }
TreeItemType Type {
get
; }
bool
IsExpanded {
get
;
set
; }
ObservableCollection<IComponentTreeItem> Children {
get
;
set
; }
IComponentTreeItem ParentItem {
get
;
set
; }
TreeItemViewSettings ViewSettings {
get
;
set
; }
}
public
class
TreeItemViewSettings
{
public
bool
CanAddChildren {
get
;
set
; }
public
bool
CanDelete {
get
;
set
; }
public
bool
CanReorder {
get
;
set
; }
public
bool
IsReadOnly {
get
;
set
; }
}
Thank you in advance!
Hallo,
i'd like to implement funcionality this: i have diagram wiht some shapes, connections groups etc. I ' d like to for example ... after double click on group open just this group in new diagram. Could you be so kind and write me some hints how to make or how to manage multiple diagrams saved in some for example list or array?
thank you
Best regards
Jakub
Hello,
I use richtextbox with XamlDataProvider, and I would like to change default font size (set it to 8) and line spacing (set it to 1) for bullets and numbered lists. It means, when the control is loaded and a user creates one of the lists, default font size and line spacing should be 8 and 1 (or other values I set in the code)
I could do such functionality for simple text, but couldn't for lists. In the attached file you can find described issue from a user point of view (if he or she started writing text without any settings changes)
Below you can also find my code.
Hope for your help.
Thanks.
XAML:
...
<
telerik:XamlDataProvider
x:Name
=
"XamlDataProvider"
Xaml
=
"{Binding ElementName=RichTextBoxControl, Path=Text, ode=TwoWay}"
RichTextBox
=
"{Binding ElementName=Editor}"
SetupDocument
=
"XamlDataProvider_OnSetupDocument"
/>
<
telerik:RadRichTextBox
Name
=
"Editor"
Grid.Row
=
"1"
PreviewMouseDoubleClick
=
"Editor_OnPreviewMouseDoubleClick"
IsSpellCheckingEnabled
=
"False"
DocumentInheritsDefaultStyleSettings
=
"True"
FontSize
=
"12"
/>
...
C#:
...
private
void
XamlDataProvider_OnSetupDocument(
object
sender, SetupDocumentEventArgs e)
{
e.Document.ParagraphDefaultSpacingAfter = 0;
e.Document.LineSpacingType = LineSpacingType.Auto;
e.Document.LineSpacing = 1;
}
...
I recently upgraded my telerik DLL's to UI for WPF Q1 2015 SP1, After upgrading i am getting error with scrollviewerstyle.
I am overriding scrollviewer style <Style TargetType="{x:Type ScrollViewer}" BasedOn="{StaticResource ScrollViewerStyle}"> .... </style> and this was working fine with older version of telerik, I had 2014 version.
I am using implicit styles so i have Syste.Windows.xaml file in my project and i am loading it in my app.xaml.cs
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/ntierHealth;component/Resources/Themes/System.Windows.xaml"/>
<ResourceDictionary Source="/ntierHealth;component/Resources/Themes/Telerik.Windows.Controls.xaml"/> .....
If i use the old version of system.windows.xaml or if i remove my style everything works but not with the latest version. I am getting StaticResourceHolder threw an exception. I have attached screen shot of the error.
Thanks
vikas
I have some columns in datagridview which can be edited. When i select a row by clicking anywhere on the row and then single click on a cell to edit, the row selection goes away.But when we double click on the cell the cell becomes editable. I also have a checkbox to select a row. Currently selection mode property of the grid is multiple. Is there a way by which single clicking on a cell will not result in deselection of the row?
Hello,
I have a column with a SumAggregateFunction.
I want to style the footer, if the sum is < 0, the foreground must be Red, if sum > 0, foreground must be Green.
I have not found how to do... Please help
I tried SelectionUnit="FullRow" to select a row with default highlights, and in RadGridView.RowStyle setting Trigger IsSelected with Value="True" to change a selection for all row with bacground colour. Nothing works properly (highlights only a cell), only IsMouseOver works that I expected.
<telerik:RadGridView x:Name=... SelectionUnit="FullRow"
... >
<telerik:RadGridView.RowStyle>
<Style TargetType="{x:Type telerik:GridViewRow}">
<Style.Triggers>
<Trigger Property="IsSelected" Value="true" >
<Setter Property="Background" Value="#CF7600"/>
</Trigger>
</Style.Triggers>
</Style>
</telerik:RadGridView.RowStyle>
Do you have any simple examples for solve this problem?
First image: http://docs.telerik.com/devtools/wpf/controls/radgridview/selection/basics.html
but it's doesn't work.