Telerik Forums
UI for WPF Forum
5 answers
203 views
Hello Telerik!

I would like to change the HierarchicalDataTemplate based off what level the user is currently on.  I am referencing a modified example that was done with the League, Division, Team example.

In my example I would like to have the treeview have the division level use the "OtherDivision" template if there are no items below.

Thanks!
Mark

<Window x:Class="WpfApplication6.MainWindow" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:local="clr-namespace:WpfApplication6" 
    xmlns:Telerik="http://schemas.telerik.com/2008/xaml/presentation"
    <Grid> 
        <Grid.Resources> 
           
            <local:LeaguesDataSource x:Key="MyList" /> 
 
            <HierarchicalDataTemplate x:Key="Division" ItemsSource="{Binding Teams}"
                <StackPanel Orientation="Horizontal"
                    <TextBlock Text="{Binding Name}" FontSize="12" /> 
                </StackPanel> 
            </HierarchicalDataTemplate> 
 
            <HierarchicalDataTemplate x:Key="OtherDivision" ItemsSource="{Binding Teams}"
                <StackPanel Orientation="Horizontal"
                    <TextBlock Text="{Binding Name}" FontSize="26" /> 
                </StackPanel> 
            </HierarchicalDataTemplate> 
 
            <HierarchicalDataTemplate x:Key="League" ItemTemplate="{StaticResource Division}" 
                    ItemsSource="{Binding Divisions}"
                <StackPanel Orientation="Horizontal"
                    <TextBlock Text="{Binding Name}" Foreground="Black" FontSize="15" /> 
                </StackPanel> 
            </HierarchicalDataTemplate> 
 
            <local:LeagueDataTemplateSelector x:Key="myDataTemplateSelector"  
                LeagueTemplate="{StaticResource League}" 
                DivisionTemplate="{StaticResource Division}" 
                OtherDivisionTemplate="{StaticResource OtherDivision}" 
             /> 
             
        </Grid.Resources> 
         
        <Grid Width="300" Height="320"
 
                <Telerik:RadTreeView  
                    VerticalAlignment="Top" 
                    ItemsSource="{Binding Source={StaticResource MyList}}" 
                    ItemTemplateSelector="{StaticResource myDataTemplateSelector}"     
                    /> 
 
        </Grid> 
    </Grid> 
</Window> 
 
Code Behind
using System; 
using System.Collections.Generic; 
using System.IO; 
using System.Text; 
using System.Windows; 
using System.Windows.Controls; 
using System.Windows.Data; 
using System.Windows.Documents; 
using System.Windows.Input; 
using System.Windows.Media; 
using System.Windows.Media.Imaging; 
using System.Windows.Shapes; 
using System.Xml.Linq; 
using System.Linq; 
 
namespace WpfApplication6 
    /// <summary> 
    /// Interaction logic for MainWindow.xaml 
    /// </summary> 
    public partial class MainWindow : Window 
    { 
        public MainWindow() 
        { 
            InitializeComponent(); 
        } 
    } 
 
    public class League 
    { 
        public League(string name) 
        { 
            _name = name; 
            _divisions = new List<Division>(); 
        } 
 
 
        string _name; 
 
        public string Name { get { return _name; } } 
 
        List<Division> _divisions; 
        public List<Division> Divisions { get { return _divisions; } } 
 
    } 
 
    public class Division 
    { 
        public Division(string name) 
        { 
            _name = name; 
            _teams = new List<Team>(); 
 
        } 
 
        string _name; 
 
        public string Name { get { return _name; } } 
 
        List<Team> _teams; 
 
        public List<Team> Teams { get { return _teams; } } 
 
    } 
 
    public class Team 
    { 
        public Team(string name) 
        { 
            _name = name; 
        } 
 
        string _name; 
 
        public string Name { get { return _name; } } 
    } 
 
    public class LeaguesDataSource : List<League> 
    { 
        public LeaguesDataSource() 
        { 
            League leagueA = new League("League A"); 
            League leagueB = new League("League B"); 
 
            Division leagueADivisionA = new Division("Division A"); 
            leagueA.Divisions.Add(leagueADivisionA); 
 
            Division leagueADivisionB = new Division("Division B"); 
            leagueA.Divisions.Add(leagueADivisionB); 
 
            Division leagueADivisionC = new Division("Division C"); 
            leagueA.Divisions.Add(leagueADivisionC); 
 
            Division leagueBDivisionA = new Division("Division A"); 
            leagueBDivisionA.Teams.Add(new Team("Team 1")); 
            leagueBDivisionA.Teams.Add(new Team("Team 2")); 
            leagueBDivisionA.Teams.Add(new Team("Team 3")); 
            leagueBDivisionA.Teams.Add(new Team("Team 4")); 
            leagueBDivisionA.Teams.Add(new Team("Team 5")); 
 
            leagueB.Divisions.Add(leagueBDivisionA); 
 
            Division leagueBDivisionB = new Division("Division B"); 
            leagueBDivisionB.Teams.Add(new Team("Team Diamond")); 
            leagueBDivisionB.Teams.Add(new Team("Team Heart")); 
            leagueBDivisionB.Teams.Add(new Team("Team Club")); 
            leagueBDivisionB.Teams.Add(new Team("Team Spade")); 
 
            leagueB.Divisions.Add(leagueBDivisionB); 
 
            Division leagueBDivisionC = new Division("Division C"); 
            leagueBDivisionC.Teams.Add(new Team("Team Alpha")); 
            leagueBDivisionC.Teams.Add(new Team("Team Beta")); 
            leagueBDivisionC.Teams.Add(new Team("Team Gamma")); 
            leagueBDivisionC.Teams.Add(new Team("Team Delta")); 
            leagueBDivisionC.Teams.Add(new Team("Team Epsilon")); 
 
            leagueB.Divisions.Add(leagueBDivisionC); 
 
            this.Add(leagueA); 
            this.Add(leagueB); 
        } 
    } 
 
    public class LeagueDataTemplateSelector : DataTemplateSelector 
    { 
        private HierarchicalDataTemplate leagueTemplate; 
        private HierarchicalDataTemplate divisionTemplate; 
        private HierarchicalDataTemplate otherDivisionTemplate; 
 
        public LeagueDataTemplateSelector() 
        { 
        } 
        public override DataTemplate SelectTemplate(object item, DependencyObject container) 
        { 
            if (item is League) 
                return this.leagueTemplate; 
            else if (item is Division) 
                return this.divisionTemplate; 
            return null; 
        } 
        public HierarchicalDataTemplate LeagueTemplate 
        { 
            get 
            { 
                return this.leagueTemplate; 
            } 
            set 
            { 
                this.leagueTemplate = value
            } 
        } 
        public HierarchicalDataTemplate DivisionTemplate 
        { 
            get 
            { 
                return this.divisionTemplate; 
            } 
            set 
            { 
                this.divisionTemplate = value
            } 
        } 
 
        public HierarchicalDataTemplate OtherDivisionTemplate 
        { 
            get 
            { 
                return this.otherDivisionTemplate; 
            } 
            set 
            { 
                this.otherDivisionTemplate = value
            } 
        } 
        
    } 

Mark Peterson
Top achievements
Rank 1
 answered on 28 May 2010
2 answers
164 views
Hi,
  I  need to draw lines between arbitrary bubbles on a bubble chart  The lines are reflective of lead-in and exiting traffic that contribute to the value of a particular bubble.  The lines may come from or go to bubbles in the current series or in another data series.
  How can I determine the coordinates of the exact center of a bubble as it is rendered in a window?

  I should mention that I have used the DataPoint object from the DataSeries object to determine the X and Y values, but am not able to translate them in a way to consistently locate the target bubble as it is rendered on the screen.   It may also be pertinent that the lines are drawn interactively after the chart is rendered and when the user selects them to be displayed on a bubble by bubble basis.
Regards,
-mark
mark
Top achievements
Rank 1
 answered on 28 May 2010
2 answers
100 views
Hi,

I have 5 items in a RadCarouselPanel and I'd like the initial behaviour of the control to show the leftmost item. Whatever i do it always seems to start with the middle item.

I've tried LineLeft, PageLeft etc etc, during the Loaded event of the control, and although programmatically these methods are having an effect on the HorizontalOffset of the control, by the time it actually displays the middle item is centred again.

What's up?

Cheers
John
jwhitley
Top achievements
Rank 1
 answered on 28 May 2010
2 answers
92 views

I have been receiving an “Object reference not set to an instance of an object.” error in the RadGridView.  I am able to receive the error by creating a new WPF Application in VS2010 and placing a RadGridView within the main window.  With the application running, click inside of the grid and press the Tab key.  Are there any settings I should change to stop the error?

adcriss
Top achievements
Rank 1
 answered on 28 May 2010
1 answer
175 views
Hello colleagues.
I've got issue. I want bind my Item to RadGridView and bind Type GridViewComboBoxColumn column
public class Item: BaseDomain 
   public virtual int Id{ getset; } 
   public virtual string Name{ getset; } 
   public virtual ItemType Type{ getset; } 
}  
 
public class ItemType : BaseDomain 
   public virtual int Id{ getset; } 
   public virtual string Name{ getset; } 
}  
  
 I use this xaml:
<telerik:GridViewComboBoxColumn Header="Type" UniqueName="Type"  
DataMemberBinding="{Binding Type.Id}"  DisplayMemberPath="Name" SelectedValueMemberPath="Id"
At grid loading I populate ItemSource of column:
((GridViewComboBoxColumn)this.grServices.Columns["Type"]).ItemsSource = Repository<ItemType>.GetAll();
 grServices.ItemsSource = Repository<Item>.GetAll();
 
The problem is that at the RowEditEnded event e.NewData.Type is null at inserting and doesn't actual at editing.
What's wrong.
Please help.
Pavel Pavlov
Telerik team
 answered on 28 May 2010
1 answer
27 views
I use test app.
When i try to search "Boston" all works fine, but when search query is "chinese restaurants in San Francisco" I receive error

---------------------------
Fatal error!
---------------------------
Error message: Search Service Exception: Неправильный результат из-за исключения, возникшего во время операции.  См. описание исключения в InnerException. 

StackTrace:    в Telerik.Windows.Controls.Map.BingSearchProvider.SearchServiceSearchCompleted(Object sender, SearchCompletedEventArgs e) в c:\Builds\WPF_Scrum\Release_WPF\Sources\Development\Controls\DataVisualization\Map\Providers\Search\BingSearchProvider.cs:строка 427

   в Telerik.Windows.Controls.Map.WPFBingSearchService.SearchServiceClient.OnSearchCompleted(Object state) в c:\Builds\WPF_Scrum\Release_WPF\Sources\Development\Controls\DataVisualization\Service References\WPFBingSearchService\Reference.cs:строка 3375

   в System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)

   в System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
Andrey
Telerik team
 answered on 28 May 2010
1 answer
31 views
Route Service Exception: An exception occurred during the operation, making the result invalid.  Check InnerException for exception details.

   at Telerik.Windows.Controls.Map.BingGeocodeProvider.GeocodeServiceReverseGeocodeCompleted(Object sender, ReverseGeocodeCompletedEventArgs e)
   at Telerik.Windows.Controls.Map.WPFBingGeocodeService.GeocodeServiceClient.OnReverseGeocodeCompleted(Object state)
   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 Storage.Inventory.App.Main() in c:\work\test\Storage.Inventory\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()
Andrey
Telerik team
 answered on 28 May 2010
5 answers
127 views
Hello,

On a grid, I set CanUserSelect to false. It works fine for mouse selection (the user cannot select a row with the mouse) but not with keyboard arrow keys.

Let me describe how to reproduce it: if you click on the grid (nothing is selected) but the grid gets the focus. Then, you use the arrow keys (up or down) and it selects the row just where you clicked (and not where the last selection was set in code)!

So, not only the user can select a row with the keyboard but "something" is also selected when clicking! Even if the selection doesn't change, the row that was clicked is still saved somewhere.

Is this a normal behavior? Am I missing an option on the grid to disable the keyboard select?
If it's a bug, do you have a workaround and when will it be corrected?

Best regards,

Daniel

EDIT: I forgot to specify that we use the Q1 2010.
Milan
Telerik team
 answered on 28 May 2010
3 answers
89 views
Hi.
We encountered a problem using the StyleManager.
We designed a (long-living ?) app which opens and closes Windows (frequently ?).
The App is running like 7 hours a day (as a try Icon) and the user con Open different Windows.
When the App starts it sets
Telerik.Windows.Controls.StyleManager.ApplicationTheme = new Telerik.Windows.Controls.Office_BlueTheme() 

When a user openes a Window he manipulates some data and closes the Window again.
For some days now we have been searching for a memory leaks (the memory in use seemed to grow)...
It turns out that no Window (and from there no controller/presenter, adapter, repository, entity-context, data-object) will ever be garbage-collected.
Upon further investigation the leak disappeared when we commented out the StyleManager-Line.
Using clr-profiler we were able to determine that references are in place from root to all/most telerik controls (and from there to the containing Window) when using an ApplicationTheme.

Ist there a way (apart from running every window in it's own AppDomain) to set a theme on aplication-level and make use of garbage-collection ?

Yours,
Nils
Nikolay
Telerik team
 answered on 28 May 2010
3 answers
103 views

Hi,

I tried the book control in my WPF application. I need to have a book cover and a different flip animation for title i.e. given as example

http://www.quranflash.com/en/quranflash.html

In this example the look and feel of first cover is like the real book title effect. Is this kind of animation possible with RadBook? Please provide help in both cases that how I can be able to achieve this hard cover effect. Thanks in advance

 

Regards,

 

Haroon

 

  


Valentin.Stoychev
Telerik team
 answered on 28 May 2010
Narrow your results
Selected tags
Tags
+? more
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?