Telerik Forums
UI for WPF Forum
1 answer
282 views
Hello,

I have a usercontrol that has a gridview in it binded to an observablecollection defined as a property of the usercontrol.
I need a 3 level cascading comboboxes on 3 columns, and I need to bind them to either properties or methods defined inside the usercontrol code behind class.
I've tried several things but I think I'm missing something, I'm kind of new to how binding works on wpf.
I'm trying to set the binding like this:

<telerik:GridViewDataColumn  
   Header="Questions" 
   DataMemberBinding="{Binding Operation, Mode=TwoWay}">     
   <telerik:GridViewDataColumn.CellEditTemplate>     
      <DataTemplate> 
         <telerik:RadComboBox DisplayMemberPath="operation" SelectedValuePath="id" 
         ItemsSource="{Binding Operations, Mode=TwoWay}" />     
      </DataTemplate> 
   </telerik:GridViewDataColumn.CellEditTemplate> 
</telerik:GridViewDataColumn> 

Where Operations is a Property of the UserControl, but I think it's trying to find Operations as a property of the Databound Object.

Any help would be appreciated.
Yavor Georgiev
Telerik team
 answered on 31 May 2010
1 answer
92 views
Hello!
I have a carousel that is using a ListCollectionView of a "CutomObject" List as ItemsSource ( for filtering purpose I need it this way )
Every time the user creates a new CustomObject, I make a refresh setting again the ItemSource of this carousel, with this new object in it.

view = new ListCollectionView( LayoutCapturer.GetSavedLayouts() ); 
            view.Filter = FilterObject; 
            this.carousel.ItemsSource = view; 
 
            this.carouselPanel.ItemsPerPage = ( carousel.Items.Count < 15 ) ? 
                ( ( carousel.Items.Count % 2 == 0 ) ? carousel.Items.Count - 1 : carousel.Items.Count ) : 15; 

But at this point I need that the top most element of the carousel to be the CustomObject I've just created.
Is that possible?

Thank you!
Roxana

Maya
Telerik team
 answered on 31 May 2010
8 answers
166 views
I have a custom RadPane control which inherits from RadPane.

I use the MVVM design pattern.

I programmatically add Panes to a RadPaneGroup contained in a DocumentHost.

I add one of my custom RadPanes. Everything is fine. Then I add another one - still fine.

I switch back to the first one and all content is gone - for example textboxes are empty, DropDownLists are in default selected state etc.

I switch back to the second one - same story.

In debug mode I can see that the custom RadPanes still have their respective ViewModel as DataContext and these ViewModel also have their properties correct but by switching between panes, these properties don't seem to bind to their respective controls (Textboxes, DropDownLists ...) anymore or the controls don't update their values correctly.


Jason Moore
Top achievements
Rank 1
 answered on 31 May 2010
1 answer
199 views
Hi.

I have a problem with setting up Selected event for RadPanelBar.
My aim is to catch an event when RadPanelBarItem is selected.

I am using DataTemplate for Item, and EntityObject entityObject containing a List<Employee>

XAML:
Resources:
<Window.Resources>   
 
<DataTemplate x:Key="RadPanelBarItemTemplate">   
 
<StackPanel MouseLeftButtonDown="pnlEmployee_MouseLeftButtonDown" Background="Transparent" Name="pnlEmployee" Orientation="Horizontal" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">   
 
<Image Source="{Binding Photo}" Stretch="Uniform" HorizontalAlignment="Left" VerticalAlignment="Stretch" Width="50" Height="50"></Image> 
 
<Label Name="lblEmployeeName" Height="50" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Content="{Binding Name}" />   
 
<Label Name="lblEmployeeID" Content="{Binding Id}" Visibility="Hidden" />   
 
</StackPanel>   
 
</DataTemplate >   
 
</Window.Resources>   
 
 

 


RadPanelBar: 

 

<telerik:RadPanelBar Grid.Row="1" Name="rpbLeftMenu" ExpandMode="Single" Selected="rpbLeftMenu_Selected">   
 
<telerik:RadPanelBarItem Name="rpbiEmployee" IsExpanded="True" ItemsSource="{Binding Employees}" ItemTemplate="{StaticResource RadPanelBarItemTemplate}">   
 
<telerik:RadPanelBarItem.Header>   
 
<StackPanel HorizontalAlignment="Left">   
 
<Label Name="lblEmployees" Content="Сотрудники"></Label>   
 
<TextBox HorizontalAlignment="Left" Name="txtEmployeesFilter" TextChanged="txtEmployeesFilter_TextChanged" Width="200"></TextBox>   
 
</StackPanel>   
 
</telerik:RadPanelBarItem.Header>   
 
</telerik:RadPanelBarItem> 
 
...  
 
</telerik:RadPanelBar>   
 

 

 

CodeBehind:

Getting data from DB:

try 
 
{   
 
IMSSDataClassesDataContext db = new IMSSDataClassesDataContext();   
 
var query = from employees in db.imss_employees   
            orderby employees.emp_lastname   
            select new { employees.emp_ID };   
 
foreach (var emp in query)   
{  
var em = db.get_employee_name_by_id(emp.emp_ID).First();   
entityObject.Employees.Add(  
new Employee(em.name, emp.emp_ID, ShowEmpImage(emp.emp_ID)));   
}  
 
rpbLeftMenu.DataContext = entityObject;  
 
}  
catch (Exception ex)   
{  
...  
}  
 


My solution for selecting Item event is to handle a StackPanel MouseLeftButtonDown event:

 

private void pnlEmployee_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)   
{  
StackPanel sp = sender as StackPanel;   
Label lb = sp.FindName("lblEmployeeID"as Label;   
this.Title = Convert.ToString(lb.Content); //just for testing purposes   
}  
 
 

But it works only when clicking correctly inside a stackpanel.

I want something like this:

  

<telerik:RadPanelBarItem Selected="RadPanelBarItem_Selected">   
<telerik:RadPanelBarItem.Header>   
<StackPanel Orientation="Horizontal" Margin="5">   
<TextBlock Text="BMW 128i Coupe" Margin="15 10 0 0" />   
</StackPanel>   
</telerik:RadPanelBarItem.Header>   
</telerik:RadPanelBarItem>   
   
private void RadPanelBarItem_Selected(object sender, Telerik.Windows.RadRoutedEventArgs e)   
{  
...  
}  
 

 

 

 

But I can't set Selected event handler for Items which are binded like mine:
ItemsSource="{Binding Employees}" 

How should I catch selection of Items?

Best regards,

Mike Ro
Top achievements
Rank 2
 answered on 31 May 2010
1 answer
76 views
Hi, I'm new to using your controls, but so far I'm liking it alot :)

I'm building a grid displaying data in a two level hierarchy which is easily achieved, but I was wondering if it was possible to display the rows of the second level in the same "master grid" in stead of generating a new gridviewdatacontrol? In my scenario this would give the best user experience.

Thanks in advance,

Best regards,
Kasper Schou
Kasper Schou
Top achievements
Rank 1
 answered on 29 May 2010
5 answers
213 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
171 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
103 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
96 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
178 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
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
Radek
Top achievements
Rank 2
Iron
Iron
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Richard
Top achievements
Rank 4
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
Radek
Top achievements
Rank 2
Iron
Iron
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Richard
Top achievements
Rank 4
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?