Telerik Forums
UI for WPF Forum
5 answers
546 views
I am having some issues getting the row that is selected in any child grid.

My main grid is a grid of Manufacturers and each row can be expanded to view each manufacturer's parts. This is no problem. The problem is getting the current row with in each expanded child grid. Here is my code so far.

public partial class ManufacturersAndPartsSearch : Window
   {
       private ViewModels.ManufacturersAndPartsSearchViewModel vm;
       public ManufacturersAndPartsSearch()
       {
           InitializeComponent();
           var context = new ViewModels.ManufacturersAndPartsSearchViewModel(this);
           this.vm = context;
           this.DataContext = vm;
 
           GridViewTableDefinition d = new GridViewTableDefinition();
           d.Relation = new Telerik.Windows.Data.PropertyRelation("ChildParts");
 
           //add child table defination to gridview
           this.GridView.ChildTableDefinitions.Add(d);
            
 
           this.GridView.DataLoaded += GridView_DataLoaded;
 
           //this is to alter changes to each child grid
           this.GridView.DataLoading += GridView_DataLoading;
 
           //event to check and set the view model's current row to a heirarchial's currently selected row if selected
 
           //explanation
           /*The original code used data binding to set the current row in the viewmodel equal to the current row in the grid
            this worked for the original purpose; however, since heirarchial grids are created for each row in the parent grid
            that has parts saved in the database then there is no way to bind their currently selected row properties to the viewmodel
             
            The databinding was ditched and instead this route was taken which accounts for both types of grids*/
           this.GridView.SelectionChanged += GridView_SelectionChanged;
       }
 
       void GridView_SelectionChanged(object sender, SelectionChangeEventArgs e)
       {
           var grid = sender as RadGridView;
           var item = grid.SelectedItem;
           this.vm.CurrentItem = item;
           MessageBox.Show(item.GetType().ToString());
       }

When my message box shows I always get a type of "PartsManufacturerViewModel". This would be correct in the parent grid because I am binding to my viewmodel's "ManufacturersAndPartsSearchViewModel.CurrentItem which is of type object. Since I am binding the grid to a collection of PartsManufacturerViewModels then this is expected. When I click on a child row I still get the same type but I should be getting PartViewModel, which is a property inside of PartsManufacturerViewModel. 

The basic gist is this. PartsManufacturerViewModel holds data relevant to the manufacturer while it has a property called "ChildParts" which is a collection of PartViewModels (which hold data relevant to the part itself). It is this collection that I bind the ChildTableDefinitions to. 

My desired outcome is to be able to set "this.vm.CurrentItem" to either a PartsManufacturerViewModel or a PartViewModel depending on the current row that is clicked once, either in the parent or the child grid.



Here is the rest of my code (ViewModels) if it helps make things clearer.

public class PartsManufacturerViewModel : Accu_Base_Lib.Bases.ModelViewModelBase<DAL.PartsManufacturer>
   {
 
 
       public string Id
       {
           get { return (string)GetValue(IdProperty); }
           set { SetValue(IdProperty, value); }
       }
 
       // Using a DependencyProperty as the backing store for Id.  This enables animation, styling, binding, etc...
       public static readonly DependencyProperty IdProperty =
           DependencyProperty.Register("Id", typeof(string), typeof(PartsManufacturerViewModel));
 
 
 
 
       public string Name
       {
           get { return (string)GetValue(NameProperty); }
           set { Debug.WriteLine("ViewModel Name Changed " + this.Name); SetValue(NameProperty, value); }
       }
 
       // Using a DependencyProperty as the backing store for Name.  This enables animation, styling, binding, etc...
       public static readonly DependencyProperty NameProperty =
           DependencyProperty.Register("Name", typeof(string), typeof(PartsManufacturerViewModel));
 
       private ObservableCollection<PartViewModel> _childParts;
 
       public ObservableCollection<PartViewModel> ChildParts
       {
           get
           {
               if (this._childParts == null)
               {
                   GetChildren();
               }
 
               return this._childParts;
           }
 
           set
           {
               this._childParts = value;
           }
       }
 
        
       public PartsManufacturerViewModel(DAL.PartsManufacturer model)
            
       {
           base.Init(model);
           //Fills this viewmodel based off the model supplied.
           UpdateViewModelFromModel();
       }
 
       public PartsManufacturerViewModel()
       {
           base.Init();
           this.Model.Id = Guid.NewGuid().ToString();
           this.Model.Name = string.Empty;
           UpdateViewModelFromModel();
       }





public class PartViewModel : Accu_Base_Lib.Bases.ModelViewModelBase<DAL.Part>
   {
 
 
       public string Id
       {
           get { return (string)GetValue(IdProperty); }
           set { SetValue(IdProperty, value); }
       }
 
       // Using a DependencyProperty as the backing store for Id.  This enables animation, styling, binding, etc...
       public static readonly DependencyProperty IdProperty =
           DependencyProperty.Register("Id", typeof(string), typeof(PartViewModel));
 
 
 
 
       public string ManufacturerId
       {
           get { return (string)GetValue(ManufacturerIdProperty); }
           set { SetValue(ManufacturerIdProperty, value); }
       }
 
       // Using a DependencyProperty as the backing store for ManufacturerId.  This enables animation, styling, binding, etc...
       public static readonly DependencyProperty ManufacturerIdProperty =
           DependencyProperty.Register("ManufacturerId", typeof(string), typeof(PartViewModel));
 
 
 
 
       public string Name
       {
           get { return (string)GetValue(NameProperty); }
           set { SetValue(NameProperty, value); }
       }
 
       // Using a DependencyProperty as the backing store for Name.  This enables animation, styling, binding, etc...
       public static readonly DependencyProperty NameProperty =
           DependencyProperty.Register("Name", typeof(string), typeof(PartViewModel));
 
 
 
 
       public string ModelNo
       {
           get { return (string)GetValue(ModelNoProperty); }
           set { SetValue(ModelNoProperty, value); }
       }
 
       // Using a DependencyProperty as the backing store for ModelNo.  This enables animation, styling, binding, etc...
       public static readonly DependencyProperty ModelNoProperty =
           DependencyProperty.Register("ModelNo", typeof(string), typeof(PartViewModel));
 
 
 
 
 
 
 
 
       public decimal Price
       {
           get { return (decimal)GetValue(PriceProperty); }
           set {
               SetValue(PriceProperty, value); }
       }
 
       // Using a DependencyProperty as the backing store for Price.  This enables animation, styling, binding, etc...
       public static readonly DependencyProperty PriceProperty =
           DependencyProperty.Register("Price", typeof(decimal), typeof(PartViewModel));
 
        
 
        
 
        
 
 
       public PartViewModel(DAL.Part model)
            
       {
           base.Init(model);
           //Fills this viewmodel based off the model supplied.
           UpdateViewModelFromModel();
       }
 
       public PartViewModel()
       {
           base.Init();
           this.Model.Id = Guid.NewGuid().ToString();
           UpdateViewModelFromModel();
       }



Dimitrina
Telerik team
 answered on 09 Jun 2014
2 answers
142 views
I have a question about the recommended theming approach to use. I get the feeling that theming aspect of telerik controls has developed a little over the years, and there now appears to be a number of possible approaches, but it's not clear to me which is the best or recommended approach to take.

If we forget about the use of the StyleManager class, from what I can tell you can there are still a number of approaches

1- Link to the required Binaries, link to the theme DLL under the same location and specify a number of resource dictionaries in the format <ResourceDictionary Source="/Telerik.Windows.Themes.Windows8;component/Themes/Telerik.Windows.Controls.xaml" />

2 - Link to the required NoXaml.Binaries, link to the theme DLL under NoXaml.Binaries as well and specify the resource dictionaries as above

3 - Link to the required Binaries, include the required XAML Themes from the Themes.implicit directory as PAge resources and specify the local resource dictionaries as  <ResourceDictionary Source="Themes/System.Windows.xaml"/>

4 - Link to the required NoXAML.Binaries, include the required XAML Themes from the Themes.implicit directory as PAge resources and specify the local resource dictionaries as  <ResourceDictionary Source="Themes/System.Windows.xaml"/>


What's the differences and which would be the best approach to take?

Cheers
Jason
Top achievements
Rank 1
 answered on 09 Jun 2014
3 answers
267 views
We have a grid and before I modified the Item and InstanceItem template, the header font was white when using the Expression_Dark theme. Now it is black. If you look at your example: http://demos.telerik.com/silverlight/#Timeline/Theming, the text changes to white to provide contrast with the dark background.

However, the back text remains present.

Paul
Evgenia
Telerik team
 answered on 09 Jun 2014
3 answers
207 views
Hello,

We have to develop a multi touch application for a large touch screen (3.50 meters).
In order to simplify the use, we would like to use complex gestures, based on several fingers / two hands instead of menus.
Is there a support for this kind of requirements in the Telerik solution, or a way to interface Telerik with GestureWorks library ?
Thanks a lot for your answer

Pascal
Nick
Telerik team
 answered on 09 Jun 2014
29 answers
1.0K+ views
I know that this has been asked in the past and that the official answer is that ItemsSource is not supported in RadPanelGroup. But this feature is a must for us and if it is not provided we will need to implement a workaround. Concretely, we need to be able to bind ItemsSource to a collection of model objects and use DataTemplates to transform them into RadPanes or a suitable class.

1. Is this feature planned for future releases of the Telerik controls?
2. If not, is there any code, either released or not, that can be used as a workaround ? One could imagine a PaneFactory that would track INotifycollectionChanges in a collection and feed the Items property of a RadPaneGroup.
3. Finally, if there is no such support code, we will have to implement it ourselves. Any gotchas that we should be aware of before starting to work on it?

Thanks in advance. I would appreciate if you could provide some answers as soon as possible.
Chris
Top achievements
Rank 1
 answered on 08 Jun 2014
1 answer
165 views

Hi,

I'm using the .dll  Telerik.Windows.Controls.Charting and in order to use implicit styles I should refer to the corresponding xaml file. I see that the telerik.windows.controls.chart.xaml exists But Not telerik.windows.controls.charting.xaml  => this results in having the charts not in the correct style.

Erdem
Top achievements
Rank 1
 answered on 08 Jun 2014
2 answers
381 views
I have a validators on my cotrols, when I am switching tabs validation errors disapear for all controls.

 <TextBox Text="{Binding SelectedJob.Well.Formation,ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged}" />


Can you suggest a fix for this problem?
Jawahar
Top achievements
Rank 1
 answered on 06 Jun 2014
2 answers
143 views
Hello,

We have to develop a multi touch application for a large touch screen (3.50 meters).
This application will allow the users to edit (at the same time) business process diagram, mainly through flowchart with vertical & horizontal swimlanes.
We have planned to use Telerik UP for WPF, but we have first to be shure that this lib will cover our requirements:
 - Multi-touch support
 - Easy way for creating flowchart: I see a demo, but it seems that the swimlanes are not really integrated in Telerik: we have to program specific shape containers
 - Connect shapes together with arrows by using a gesture

Could you please provide me with some advices ?
Thanks a lot

Pascal
Pascal
Top achievements
Rank 1
 answered on 06 Jun 2014
2 answers
88 views
With the new DragDropManager (instead of RadDragAndDropManager), how to get the PropertyGridField when mouse is dragging over it?
De
Top achievements
Rank 1
 answered on 06 Jun 2014
7 answers
470 views
I have a problem where setting the MaximumTicks on a DateTimeContinousAxis causes the Bars on a BarSeries to be drawn incorrectly for large numbers of bars. Below is an example showing the problem.

If you run the example, you can see that initially the bars correspond to the line series plotting the same data (ignoring the aliasing effect of too many bars for the number of pixels to display them on). However, you have way too many labels to display on the X axis, and a solid grey background due to the number of grid lines.

Now, use the box at the bottom to change the value of MaximumTicks (note that this is the first time it's being set). Now the bars do not appear to correspond to the line series. (My theory is that they're being drawn way too wide.) The labels and grid lines now look good, however.

Now drag the right zoom handle on the horizontal axis as far left as possible (maximum zoom at the start of the series). You see similar effects to the zoomed out view. 

Now, again use the box at the bottom to change the value of MaximumTicks and the display goes back to what is expected. Now you can zoom back out, and you still have the expected view where the bars match the line.

Is there another way to filter down the number of labels and grid lines and get the bars to draw at a reasonable width? I tried GapLength, but this didn't resolve the problem (0.95 looks much better, but they're still overlapping a bit, 0.5 looks the same as without).

Thanks,
Louis

XAML:
<Window x:Class="BarDensity.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"
                xmlns:local="clr-namespace:BarDensity"
                Title="MainWindow" Height="750" Width="1000">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <telerik:RadCartesianChart Margin="5" x:Name="PropertyChart">
            <telerik:RadCartesianChart.Behaviors>
                <telerik:ChartPanAndZoomBehavior ZoomMode="Both" PanMode="Both" />
            </telerik:RadCartesianChart.Behaviors>
            <telerik:RadCartesianChart.Grid>
                <telerik:CartesianChartGrid MajorLinesVisibility="XY" />
            </telerik:RadCartesianChart.Grid>
            <telerik:RadCartesianChart.HorizontalAxis>
                <telerik:DateTimeContinuousAxis LabelFitMode="Rotate" LabelFormat="yyyy-MMM" GapLength="0.5"/>
            </telerik:RadCartesianChart.HorizontalAxis>
            <telerik:RadCartesianChart.VerticalAxis>
                <telerik:LinearAxis />
            </telerik:RadCartesianChart.VerticalAxis>
 
            <telerik:RadCartesianChart.Series>
                <telerik:BarSeries CategoryBinding="Date"
                       ValueBinding="Value"
                       ItemsSource="{Binding Path=Series1}">
                    <telerik:BarSeries.PointTemplate>
                        <DataTemplate>
                            <Rectangle Fill="Blue" />
                        </DataTemplate>
                    </telerik:BarSeries.PointTemplate>
                </telerik:BarSeries>
                <telerik:LineSeries CategoryBinding="Date"
                       ValueBinding="Value"
                       ItemsSource="{Binding Path=Series1}"
                       Stroke="Red">
                </telerik:LineSeries>
            </telerik:RadCartesianChart.Series>
        </telerik:RadCartesianChart>
        <StackPanel Grid.Row="1" Orientation="Horizontal">
            <Label>MaximumTicks:</Label>
            <telerik:RadNumericUpDown IsEditable="True" Minimum="10" Maximum="50"
                                      Value="{Binding Path=MaximumTicks}"/>
        </StackPanel>
    </Grid>
</Window>

Code Behind:
namespace BarDensity
{
    public class MyPoint
    {
        public DateTime Date { get; set; }
        public Double Value { get; set; }
    }
    public partial class MainWindow : Window
    {
        private int _MaximumTicks = 20;
        public List<MyPoint> Series1 { get; private set; }
        public int MaximumTicks
        {
            get { return _MaximumTicks; }
            set
            {
                if (_MaximumTicks != value)
                {
                    _MaximumTicks = value;
                    DateTimeContinuousAxis dateAxis = PropertyChart.HorizontalAxis as DateTimeContinuousAxis;
                    if (dateAxis != null)
                        dateAxis.MaximumTicks = _MaximumTicks;
                }
            }
        }
        public MainWindow()
        {
            Series1 = new List<MyPoint>();
            DateTime startDate = new DateTime(2014, 1, 1);
            for (int i = 0; i < 1000; i++)
                Series1.Add(new MyPoint() { Date = startDate.AddMonths(i),
                    Value = (Math.Sin(i / 100.0)) * 500 });
            InitializeComponent();
            DataContext = this;
        }
    }
}

Petar Marchev
Telerik team
 answered on 06 Jun 2014
Narrow your results
Selected tags
Tags
GridView
General Discussions
Chart
RichTextBox
Docking
ScheduleView
ChartView
TreeView
Diagram
Map
ComboBox
TreeListView
Window
RibbonView and RibbonWindow
PropertyGrid
DragAndDrop
TabControl
TileView
Carousel
DataForm
PDFViewer
MaskedInput (Numeric, DateTime, Text, Currency)
AutoCompleteBox
DatePicker
Buttons
ListBox
GanttView
PivotGrid
Spreadsheet
Gauges
NumericUpDown
PanelBar
DateTimePicker
DataFilter
Menu
ContextMenu
TimeLine
Calendar
Installer and Visual Studio Extensions
ImageEditor
BusyIndicator
Expander
Slider
TileList
DataPager
PersistenceFramework
Styling
TimeBar
OutlookBar
TransitionControl
FileDialogs
Book
ToolBar
ColorPicker
TimePicker
MultiColumnComboBox
SyntaxEditor
VirtualGrid
NavigationView (Hamburger Menu)
Wizard
ExpressionEditor
WatermarkTextBox
DesktopAlert
BarCode
SpellChecker
DataServiceDataSource
EntityFrameworkDataSource
RadialMenu
ChartView3D
Data Virtualization
BreadCrumb
LayoutControl
ProgressBar
Sparkline
TabbedWindow
ToolTip
CloudUpload
ColorEditor
TreeMap and PivotMap
EntityFrameworkCoreDataSource (.Net Core)
HeatMap
Chat (Conversational UI)
VirtualizingWrapPanel
Calculator
NotifyIcon
TaskBoard
TimeSpanPicker
BulletGraph
Licensing
WebCam
CardView
DataBar
FilePathPicker
Callout
PasswordBox
SplashScreen
Localization
Rating
Accessibility
CollectionNavigator
AutoSuggestBox
Security
VirtualKeyboard
HighlightTextBlock
TouchManager
StepProgressBar
Badge
OfficeNavigationBar
ExpressionParser
CircularProgressBar
SvgImage
PipsPager
SlideView
AI Coding Assistant
InlineAIAssistant
+? more
Top users last month
Tien
Top achievements
Rank 1
Iron
Krasimir
Top achievements
Rank 3
Bronze
Iron
Iron
Cedar
Top achievements
Rank 1
Iron
Emil
Top achievements
Rank 1
Iron
Kyle Watson
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Tien
Top achievements
Rank 1
Iron
Krasimir
Top achievements
Rank 3
Bronze
Iron
Iron
Cedar
Top achievements
Rank 1
Iron
Emil
Top achievements
Rank 1
Iron
Kyle Watson
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?