Telerik Forums
UI for WPF Forum
1 answer
422 views
I have a RadTreeView bound in an MVVM style application. If a selection does not contain Details I need to disable the ability to click on that node and keep the currently selected node highlighted. The user should still able to expand and collapse.

I have tried to bind to PreviewSelected but the SelectedItem property still gets hit even if I switch e.handled = true and I lose the node highlighting on the currently selected node. 

<
UserControl.Resources>
    <ResourceDictionary>
        <Style x:Key="PHToCItemContainerStyle" TargetType="{x:Type telerik:RadTreeViewItem}" BasedOn="{StaticResource RadTreeViewDefaultItemPlusMinusStyle}">
            <Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}"/>
            <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}"/>
        </Style>
        <DataTemplate x:Key="Measure">
            <TextBlock Text="{Binding Name }" Style="{StaticResource RadTreeViewItemSelectedTextBlockDefaultStyle}" VerticalAlignment="Center"/>
        </DataTemplate>
        <HierarchicalDataTemplate x:Key="Condition" ItemTemplate="{StaticResource Measure}" ItemsSource="{Binding Measures}">
            <TextBlock Text="{Binding Name}" Style="{StaticResource RadTreeViewItemSelectedTextBlockDefaultStyle}" />
        </HierarchicalDataTemplate>
        <HierarchicalDataTemplate x:Key="ConditionGroup" ItemTemplate="{StaticResource Condition}" ItemsSource="{Binding Conditions}" >
            <TextBlock Text="{Binding Name }" FontWeight="Bold" Style="{StaticResource RadTreeViewItemSelectedTextBlockDefaultStyle}" />
        </HierarchicalDataTemplate>
    </ResourceDictionary>
</UserControl.Resources>
 
...
 
<telerik:RadTreeView
    x:Name="RadTree"     
    telerik:TextSearch.TextPath="Name"   
    VirtualizingStackPanel.IsVirtualizing="True"
    VirtualizingStackPanel.VirtualizationMode="Recycling"
    ItemsSource="{Binding ResultObject}"
    Style="{StaticResource RadTreeViewDefaultPlusMinusStyle}"
    ExpanderStyle="{StaticResource RadTreeViewDefaultPlusMinusExpanderStyle}"
    ItemTemplate="{StaticResource ConditionGroup}"
    ItemContainerStyle="{StaticResource PHToCItemContainerStyle}"
    SelectedItem="{Binding ResultObject.SelectedIndexItem}" />

dll version = 2014.1.331.45
Martin Ivanov
Telerik team
 answered on 11 Mar 2015
16 answers
555 views
When I load my layout all of my binding content is gone.  I had a similar issue with Header content on a RadDocumentPane and the solution was to use a HeaderTemplate.  This did resolve my issue with the header but when I try a similar approach with a ContentTemplate I have no success.

Is there a way to preserve my RadPane content when I load the layout?

I have the following XAML:

 

 

 

<telerik:RadPane x:Name="rpIndexPane" CanUserClose="False" ContextMenuTemplate="{x:Null}" CanDockInDocumentHost="False" Header="Index"

 

 

 

telerik:RadDocking.SerializationTag="IndexPane" DataContext="{Binding}">

 

 

 

 

<ItemsControl DataContext="{Binding}" ItemsSource="{Binding ActiveJob.Patient.CurrentVisit.Sections.Items}" HorizontalContentAlignment="Stretch">

 

 

 

 

<ItemsControl.Template>

 

 

 

 

<ControlTemplate TargetType="ItemsControl">

 

 

 

 

<ScrollViewer VerticalScrollBarVisibility="Auto">

 

 

 

 

<ItemsPresenter/>

 

 

 

 

</ScrollViewer>

 

 

 

 

</ControlTemplate>

 

 

 

 

</ItemsControl.Template>

 

 

 

 

<ItemsControl.ItemTemplate>

 

 

 

 

<DataTemplate>

 

 

 

 

<Button Background="{Binding Color}" Margin="1" Visibility="{Binding Visible, Converter={StaticResource BoolToVisConverter}}">

 

 

 

 

<TextBlock Text="{Binding Name}" Margin="3,5,3,5" HorizontalAlignment="Center"></TextBlock>

 

 

 

 

</Button>

 

 

 

 

</DataTemplate>

 

 

 

 

</ItemsControl.ItemTemplate>

 

 

 

 

</ItemsControl>

 

 

 

 

</telerik:RadPane>

 

Kalin
Telerik team
 answered on 11 Mar 2015
12 answers
254 views
Is it possible to take objectmodel and pass each objects "ID" property to an expressioneditor as a field? or maybe each column id in a datatable?
Dimitrina
Telerik team
 answered on 11 Mar 2015
1 answer
215 views
Hello,
 
I have a RadDiagram in which I load 400 items with almost 50 binding properties per-item, like for example BackgroundColor, FontSize, Width, Height, Visibility, etc…

Example of BackgroundColor property for binding: 

private Brush backgroundColor ;
public Brush BackgroundColor
{
      get{ return backgroundColor; }
      set
      {
              backgroundColor = value;
              OnPropertyChanged(“BackgroundColor”);
      }


Each item is a derived class from MyNode:NodeViewModelBase with DataTemplate:  

<telerik:RadDiagram.ShapeStyle>               
       <Style TargetType="telerik:RadDiagramShape">
               <Setter Property="Position" Value="{Binding Position, Mode=TwoWay}" />                  
               <Setter Property="Background" Value="{Binding BackgroundColor} " />                   
               <Setter Property="BorderBrush" Value="Transparent" />
               ……………

The performance is very bad. It last up to 5 seconds to display the whole diagram with all items over it.  

Any help to enhance the performance?
Pavel R. Pavlov
Telerik team
 answered on 11 Mar 2015
1 answer
153 views
Hello. I kind of necroposted in other thread about this issue. That thread seems to be inactive though, so I thought I might as well start a new one, and add some context.

So, long story short, I am trying to implement MVVM with RadDocking and I am having troubles with data binding. Whenever I call LoadLayout method all the binidings that were set in templates break, and i don't know how to fix them.

This is the global style, I'm applying to RadPanes:

<DataTemplate x:Key="HeaderTemplate">
    <StackPanel Orientation="Horizontal">
        <Image Margin="0,0,3,0" Source="{Binding Screen.IconSource}" Width="16" Height="16""/>
        <TextBlock Text="{Binding Screen.Title}"/>
    </StackPanel>
</DataTemplate>
 
<Style TargetType="{x:Type Controls:RadPane}">
    <Setter Property="HeaderTemplate" Value="{StaticResource HeaderTemplate}"/>
    <Setter Property="TitleTemplate" Value="{StaticResource HeaderTemplate}"/>
</Style>

This is my viewmodel class which represents a single pane:
public class ScreenViewModel
{
        public ScreenViewModel(IScreen screen)
        {
            Screen = screen;
        }
 
        public IScreen Screen { get; private set; }
         
        private RadPane _pane;
          //this property is set in DockingPanesFactory.CreatePaneForItem method
        public RadPane Pane
        {
            get { return _pane; }
            set
            {
                _pane = value;
                _pane.Content = Screen.View;
                _pane.Header = this;
                RadDocking.SetSerializationTag(_pane, Screen.ContentId);
            }
        }
//+some other irrelevant properties
}
 
//this is my model
interface IScreen
{
    UIElement View { get; }
    string Title { get; }
    string ContentId { get; }
    ImageSource IconSource { get; }
}

And this is how I load the layout:
public ObservableCollection<ScreenViewModel> Screens { get; set; }
 
public void Load(string file, IScreenFactory screenFactory)
{
    if (!File.Exists(file)) return;
    Screens.Clear();
    using (var fs = File.OpenRead(file))
    {
        var doc = XDocument.Load(fs);
        foreach (var screenId in doc.Descendants("RadPane").Select(x => x.Attribute("SerializationTag").Value))
        {
            //some factory wich creates models by their IDs
            IScreen screen = screenFactory.RestoreScreen(screenId);
            Screens.Add(new ScreenViewModel(screen));
        }
        if (Screens.Any())
        {
            fs.Position = 0;
            //after this call all template the bindings break
            _radDocking.LoadLayout(fs);
        }
    }
}
After the LoadLayout call I can see that header content is set, and that the template is applied, but the bindings set by this template are broken (VS Output is flooded by binding exceptions), which results in empty pane headers. What am I doing wrong?

Nikita
Top achievements
Rank 1
 answered on 11 Mar 2015
9 answers
513 views
Hi

I created a new wpf app and followed the information in the forum to make the main window a RadWindow.  When I execute the program I get a wpf navigation window with my RadWindow inside of it.   The RadWindow appears to be frozen,  Outside the Navigation window is another RadWindow that is not frozen.  Based on the forum guide I think I am doing everything correctly.  I am also using the latest version of the telerik libraries.  I am expecting to see only a main RadWindow with no navigation window.

1. - Created a new Wpf Application

2. Modified MainWindow.Xaml 

<telerik:RadWindow x:Class="CloudburstDataReader.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"
        Header="Cloudburst Data Reader" Height="350" Width="525">
    <Grid>

    </Grid>
</telerik:RadWindow>

3. Modified App.xaml.cs

public partial class App : Application
    {
        protected override void OnStartup(StartupEventArgs e)
        {
            new MainWindow().Show();
            base.OnStartup(e);
        }

    }

4. Modified CloudburstDataReader.cs

namespace CloudburstDataReader
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : RadWindow
    {
        public MainWindow()
        { 
            InitializeComponent();
        }
    }
}


    
ToddR
Top achievements
Rank 1
 answered on 10 Mar 2015
2 answers
97 views
When I bind a GridViewDataColumn to a DateTime field, I am not allowed to set the Time.  Seems like a reasonable expectation. 

The default state of the column seems to give us the worst of both worlds because the time is displayed when not edited but when we are in edit mode I can't change it.  If the default is just a calendar then don't display the time in the column.  If the default is to handle time then expose the RadDateTimeEditor instead of the RadDateEditor while editing.

How can I accomplish what I want?  Is it a setting in XAML or do I need to capture the column on creation and define it differently?  I'm always appreciative of XAML and Code examples.

Joel.
Joel Palmer
Top achievements
Rank 2
 answered on 10 Mar 2015
1 answer
183 views
Hi,

I am creating a wpf application with MVVM pattern. The application has a radscheduleview component with context menu attached to it. When user select the "Delete Note" menu item, how can I get all selected appointments into the list which I can then go through, and do desired manipulations to each appointment?

Currently I have a command which delete one appointment at a time. A new requirement is deletion of all selected appointments. Any ideas?

        public RelayCommand<CustomAppointment> DeleteNoteCommand
        {
            get
            {
                return deleteNoteCommand
                    ?? (deleteNoteCommand = new RelayCommand<CustomAppointment>(
                                          p =>
                                          {
                                              if (p != null)
                                              {
                                                  var message = new DialogMessage("Delete Note?", DeleteNoteCallback)
                                                  {
                                                      Button = MessageBoxButton.OKCancel,
                                                      Caption = "Delete Note",
                                                      Icon = MessageBoxImage.Warning
                                                  };
                                                  deletedNote = p; // global variable to send selected item to messenger
                                                  Messenger.Default.Send(message);
                                              }
                                          },
                                          p => (p != null) && (p.Source == NOTE));
            }
        }
Nasko
Telerik team
 answered on 10 Mar 2015
1 answer
166 views
Hi, in the following code I get an exception when i try to drag the content (not the header) of a RadTileViewItem

<Window x:Class="TelerikTest.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">
  <Window.Resources>
    <ResourceDictionary>
      <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="Themes/VisualStudio2013/Themes/System.Windows.xaml" />
        <ResourceDictionary Source="Themes/VisualStudio2013/Themes/Telerik.Windows.Controls.Docking.xaml" />
        <ResourceDictionary Source="Themes/VisualStudio2013/Themes/Telerik.Windows.Controls.Navigation.xaml" />
        <ResourceDictionary Source="Themes/VisualStudio2013/Themes/Telerik.Windows.Controls.xaml" />
      </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>

  </Window.Resources>
  <telerik:RadDocking>
    <telerik:RadDocking.DocumentHost>
      <telerik:RadPaneGroup x:Name="Group1">
        <telerik:RadPane x:Name="Pane1" Header="Server Explorer">
          <telerik:RadTileView>
            <telerik:RadTileViewItem Header="Test">
              <TextBlock Text="Start to drag here to crash"/>
            </telerik:RadTileViewItem>
          </telerik:RadTileView>
        </telerik:RadPane>
      </telerik:RadPaneGroup>
    </telerik:RadDocking.DocumentHost>
  </telerik:RadDocking>
  
</Window>

Am I doing something wrong here? I tried it in in Q1 2015 release and in a release from 2014

The last part of stacktrace is

An unhandled exception of type 'System.NullReferenceException' occurred in Telerik.Windows.Controls.Docking.dll

  Telerik.Windows.Controls.Docking.dll!Telerik.Windows.Controls.RadPane.OnDragInitialize(object sender, Telerik.Windows.DragDrop.DragInitializeEventArgs e) Unknown
  Telerik.Windows.Controls.dll!Telerik.Windows.DragDrop.DragInitializeEventArgs.InvokeEventHandler(System.Delegate genericHandler, object genericTarget) Unknown
  PresentationCore.dll!System.Windows.RoutedEventArgs.InvokeHandler(System.Delegate handler, object target) Unknown
  PresentationCore.dll!System.Windows.EventRoute.InvokeHandlersImpl(object source, System.Windows.RoutedEventArgs args, bool reRaised) Unknown
  PresentationCore.dll!System.Windows.UIElement.RaiseEventImpl(System.Windows.DependencyObject sender, System.Windows.RoutedEventArgs args) Unknown
  Telerik.Windows.Controls.dll!Telerik.Windows.DragDrop.DragInitializer.StartDrag() Unknown
  Telerik.Windows.Controls.dll!Telerik.Windows.DragDrop.DragInitializer.StartDragPrivate(System.Windows.UIElement sender) Unknown
  Telerik.Windows.Controls.dll!Telerik.Windows.DragDrop.DragInitializer.DragSourceOnMouseMove(object sender, System.Windows.Input.MouseEventArgs e) Unknown
  PresentationCore.dll!System.Windows.RoutedEventArgs.InvokeHandler(System.Delegate handler, object target) Unknown


...
Geri
Telerik team
 answered on 10 Mar 2015
3 answers
149 views
How can add possibility for selecting range of chart using radcartesianchart?
Milena
Telerik team
 answered on 10 Mar 2015
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?