Telerik Forums
UI for WPF Forum
3 answers
376 views
Hi.
There's a way to Bind the LoadOnDemand Event to a Command in a MVVM Pattern.
I'm using Galasoft MVVM Light in my application and I load the data from WCF services. All is ok, but now I've to manage the LoadOnDemand Event without breaking the MVVM pattern.

I've tryied using the EventToCommand of Galasoft and its works fine. This is the XAML code
<UserControl 
  x:Class="FB_BridgeArchive.View.JobsView"
  xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
  xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WPF4"
  xmlns:telerikQuickStart="clr-namespace:Telerik.Windows.Controls.QuickStart;assembly=Telerik.Windows.Controls"
  mc:Ignorable="d" d:DesignWidth="300" d:DesignHeight="400"
  DataContext="{Binding Jobs, Source={StaticResource Locator}}">
  
  <UserControl.Resources>
    <DataTemplate x:Key="CategoryTemplate">
      <TextBlock Text="{Binding Description}" />
    </DataTemplate>
    <HierarchicalDataTemplate x:Key="LevelTemplate" ItemsSource="{Binding Categories}" ItemTemplate="{StaticResource CategoryTemplate}">
      <TextBlock Text="{Binding Description}" />
    </HierarchicalDataTemplate>
    <HierarchicalDataTemplate x:Key="TeacherTemplate" ItemsSource="{Binding Levels}" ItemTemplate="{StaticResource LevelTemplate}">
      <TextBlock Text="{Binding Name}" />
    </HierarchicalDataTemplate>
  </UserControl.Resources>
    
  <StackPanel Orientation="Vertical">
    <telerik:RadTreeView x:Name="jobTreeView" Margin="8" ExpanderStyle="{StaticResource ExpanderStyle}"
                         IsLoadOnDemandEnabled="True" IsExpandOnSingleClickEnabled="True"
                         ItemTemplate="{StaticResource TeacherTemplate}" ItemsSource="{Binding Path=Ds.Teachers}">
    <i:Interaction.Triggers>
      <i:EventTrigger EventName="LoadOnDemand">
        <cmd:EventToCommand PassEventArgsToCommand="True" Command="{Binding LoadOnDemand}" />
      </i:EventTrigger>
    </i:Interaction.Triggers>
  </telerik:RadTreeView>
  </StackPanel>
</UserControl>
As you can see I call the LoadOnDemand Command in my ViewModel.
Now, in the ViewModel I've the followind method to handle the LoadOnDemand:
private void HandleLoadOnDemand(RadRoutedEventArgs e)
{
  RadTreeViewItem item = e.OriginalSource as RadTreeViewItem;
  if (item.Item.GetType() == typeof(WcfTeacher))
  {
    Ds.LoadLevels(item.Item as WcfTeacher);
  }
  else if (item.Item.GetType() == typeof(WcfLevel))
  {
    Ds.LoadCategories(item.Item as WcfLevel);
  }
  else
    item.IsLoadOnDemandEnabled = false;
}
It works, but with a problem.
When you click on an item, the method is called and the items are loaded, but you don't see them on the TreeView. You need to click on the item one more time in order to see the item expanded.
Why? 
I've forgotten something, or there's some other problems?
Maybe it's the wrong way to bind the LoadOnDemand event, but there's a better way? 

Thanks a lot and regards.
Andrea
Miroslav
Telerik team
 answered on 26 Aug 2010
1 answer
69 views
Hello,

Can you tell me what events do occur when I use the needle interactive within a gauge?

David Groenewegen
Andrey
Telerik team
 answered on 26 Aug 2010
1 answer
175 views
What is the best way to bind the items of a carousel to a column (images that are of type byte[]) of a gridView which is itself bound to a database table.  I ultimately want to populate the carousel with only the images from the selected rows in the gridView.  Any pointers would be appreciated.

Thanks,
Nate
Maya
Telerik team
 answered on 26 Aug 2010
1 answer
348 views
i have this grid

 

 

<telerik:RadGridView x:Name="grid" ItemsSource="{Binding Path(ns:class.property)}"

 

 

 

SelectionMode="Single"

 

 

 

ShowGroupPanel="False" AutoGenerateColumns="False" CanUserDeleteRows="False" CanUserFreezeColumns="False" CanUserInsertRows="False" CanUserReorderColumns="False" CanUserResizeColumns="False"

 

 

 

RowIndicatorVisibility="Collapsed" Controls:StyleManager.Theme="Office_Black" EnableColumnVirtualization="False" EnableRowVirtualization="False" IsFilteringAllowed="False" Controls:RadControl.Theme="Office_Black" ReorderColumnsMode="None"
/>

now when i try to change selected item from code like this:

grid.SelectedItem = Collection[0];

the grid.SelectedItem stays null
even though Collection[0] is not null

i tried to call OnApplyTemplate before assignment but it didn't helped

i tried to do it with two way data binding and it didn't helped too

what can cause this?
and how can i solve it?

thanks

 

 

igal a
Top achievements
Rank 1
 answered on 26 Aug 2010
3 answers
98 views
Hi!

I'm adding from the code an object to one of my recursive ObservableCollection. There is a root ObservableCollection that is set as ItemsSource. 

When I add it to my collection, I want to select it on my tree.

So how can do this? I cannot find any methods that permits me to get a RadTreeViewItem of my added object.

I've seen that: http://www.telerik.com/help/wpf/radtreeview-how-to-get-item-by-path.html but I'm not sure there will never two element with the same displayed name
Milan
Telerik team
 answered on 26 Aug 2010
6 answers
582 views
Hello!
Is there a way to iterate over a RadDocking control  and check which RadPanes are floating, ans eventually make them docked also from code?

Thank you!
Roxana
RoxanaC
Top achievements
Rank 1
 answered on 26 Aug 2010
1 answer
120 views
Hi there,

I have an RadPane and inside a RadTreeView. When I now change the width of the pane (by runtime) the width of the RadTreeView does not change. Equally when I undock the pane.
What did I have to do that the RadTreeView always has the width of the RadPane?

Thx
Andi
Andi
Top achievements
Rank 2
 answered on 26 Aug 2010
1 answer
309 views
Hi All,
I have a radbutton where i have an image and a text block as its content. The image and text appears in design, but in runtime 
only text gets displayed the image doesn't appear can anyone please get e around this issue.

TIA,

Regards
Sampath
Miroslav
Telerik team
 answered on 26 Aug 2010
5 answers
116 views
I have a tile view something like what is below. How to I set the colors of the tiles in this scenario?

<telerik:RadTileView Margin="12" Name="DashboardRadTileView" ItemsSource="{Binding}" Grid.Row="2" BorderBrush="{DynamicResource BorderBrush}" Background="{DynamicResource PanelGradientBrush}" Foreground="Black" MinimizedItemsPosition="Bottom" Padding="12">
    <telerik:RadTileView.ItemTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding Path=Description}" />
        </DataTemplate>
    </telerik:RadTileView.ItemTemplate>
    <telerik:RadTileView.ContentTemplate>
        <DataTemplate>
            <StackPanel>
                <TextBlock Text="{Binding Path=Text}"/>
            </StackPanel>
        </DataTemplate>
    </telerik:RadTileView.ContentTemplate>
</telerik:RadTileView>
Kiril Stanoev
Telerik team
 answered on 26 Aug 2010
3 answers
173 views
Hi there,

I want to add images to my TreeViewItems, but it does not work :(
I knew there are many Threads for this theme and I read many of them, but I found no answer which can help me.
I have just a simple .xaml with the Tree and 3 Items and a folder named "Icons" in the source-folder of my project.
What am I doing wrong?

<Window x:Class="TreeViewTest.MainWindow"
        Title="MainWindow" Height="350" Width="525" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" Icon="/TreeViewTest;component/ics.ico">
    <Grid>
        <telerik:RadTreeView  HorizontalAlignment="Left"  Name="treeView1" VerticalAlignment="Top" IsLineEnabled="True" FontFamily="Arial" FontSize="10" ImagesBaseDir="/Icons/" IsDragPreviewEnabled="False">
            <telerik:RadTreeViewItem Header="Global" DefaultImageSrc="Folder_16x16-32.png">
                <telerik:RadTreeViewItem Header="Local 1" />
                <telerik:RadTreeViewItem Header="Local 2" />
            </telerik:RadTreeViewItem>
        </telerik:RadTreeView>       
    </Grid>
</Window>
Tina Stancheva
Telerik team
 answered on 26 Aug 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?