Telerik Forums
UI for WPF Forum
1 answer
453 views
Hi,

I saw a similar issue posted in the Silverlight forum. I am not able to use the solution presented there because I need to instantiate my view model with parameters from the view. I am trying to bind a Composite WPF DelegateCommand to a column cell template in my RadGridView.

When I run the application I get this error in the output window:
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'ElementName=LayoutRoot'. BindingExpression:Path=DataContext.StopCommand; DataItem=null; target element is 'Button' (Name='StopButton'); target property is 'Command' (type 'ICommand')

If I bind the command to a button outside the RadGridView it works as expected.

I have the following XAML:
<Window x:Class="MVVMCommand.MainWindow" 
        x:Name="LayoutRoot" 
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        Title="MainWindow" Height="300" Width="300" 
        xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
    <StackPanel> 
        <Button Content="This one works" 
                CommandParameter="42" 
                Command="{Binding ElementName=LayoutRoot, Path=DataContext.StopCommand}" /> 
            <telerik:RadGridView Name="radGridView1" ItemsSource="abcd"
            <telerik:RadGridView.Columns> 
                <telerik:GridViewColumn Header="Start"
                    <telerik:GridViewColumn.CellTemplate> 
                        <DataTemplate> 
                            <Button Content="This one does not"
                                    CommandParameter="42" 
                                    Command="{Binding ElementName=LayoutRoot, Path=DataContext.StopCommand}" /> 
                        </DataTemplate> 
                    </telerik:GridViewColumn.CellTemplate> 
                </telerik:GridViewColumn> 
            </telerik:RadGridView.Columns> 
        </telerik:RadGridView> 
    </StackPanel> 
</Window> 

The view model looks like this:
using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using Microsoft.Practices.Composite.Presentation.Commands; 
 
namespace MVVMCommand 
    public class MVVMCommandViewModel 
    { 
        public DelegateCommand<object> StopCommand { getset; } 
 
        public MVVMCommandViewModel(string s
        { 
            StopCommand = new DelegateCommand<object>(StopCommand_Execute); 
        } 
 
        void StopCommand_Execute(object o) 
        { 
 
        } 
    } 

My code-behind:
    public partial class MainWindow : Window 
    { 
        MVVMCommandViewModel _viewModel; 
 
        public MainWindow() 
        { 
            InitializeComponent(); 
            _viewModel = new MVVMCommandViewModel("42"); 
            this.DataContext = _viewModel; 
        } 
    } 

Maya
Telerik team
 answered on 25 Jun 2010
1 answer
192 views
Hi ,

I am using Telerik WPF version : 2009.1.xxx.xx
WPF window screen i place the following line:
 <telerik:RadDatePicker x:Name="dtpDate"  SelectedDate="{Binding ReferredToDate, Mode=TwoWay, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, UpdateSourceTrigger=PropertyChanged }"  SelectionChanged="dtpDate_SelectionChanged"/>

When i input  digit Zero(0) in datetime picker and press tab i gett following error :

Year, Month, and Day parameters describe an un-representable DateTime.

BECAUSE OF THIS ERROR EVEN IT NOT FIRE THE PROPERTY CHANGED EVENT..

HOW TO HANDLE THIS ISSUE ?

Thanks in advance
Hiren
Kaloyan
Telerik team
 answered on 25 Jun 2010
2 answers
112 views
Hi,

I've been looking through the DataGrid documentation (the WPF Demos, looking at the code behind) and there is a CellTemplateSelector property used:

<telerik:GridViewDataColumn Header="UnitPrice" DataMemberBinding="{Binding UnitPrice}" 
                            CellTemplateSelector="{StaticResource selector}" DataFormatString="{}{0:c}" /> 
(Demo: Controls -> Data -> GridView -> DataTemplateSelectors -> Templating cells -> example.xaml)

Im using the RadControls for WPF Q1 2010 SP2, however this property does not appear, I can set the property CellTemplate property but not a CellTemplateSelector. Should this be possible?

<telerik:GridViewDataColumn UniqueName="direction"   
                            Header="Direction" DataMemberBinding="{Binding Path=eventDirection}"/> 

Thank you,
Toby
Top achievements
Rank 1
 answered on 25 Jun 2010
1 answer
81 views

Hi,

i have tried following thing for Stick chart. Following thing is worling fine now issue:

public partial class MainPage : UserControl  
    {  
        public MainPage()  
        {  
            InitializeComponent();  
 
            InitializeChart();  
        }  
 
        private void InitializeChart()  
        {  
            Telerik.Windows.Controls.Charting.StickSeriesDefinition cssd = new StickSeriesDefinition();  
            cssd.ShowItemToolTips = true;             
 
 
            telerikChart.DefaultSeriesDefinition = cssd;  
            telerikChart.ItemsSource = GetStocks();  
            SeriesMapping sm=new SeriesMapping();  
            sm.ItemMappings.Add(new ItemMapping("Name", DataPointMember.XCategory));  
            sm.ItemMappings.Add(new ItemMapping("Open",DataPointMember.Open));  
            sm.ItemMappings.Add(new ItemMapping("Close", DataPointMember.Close));  
            sm.ItemMappings.Add(new ItemMapping("Low", DataPointMember.Low));  
            sm.ItemMappings.Add(new ItemMapping("High", DataPointMember.High));  
            sm.ItemMappings.Add(new ItemMapping("High", DataPointMember.Tooltip));  
              
 
            telerikChart.SeriesMappings.Add(sm);  
            telerikChart.DefaultSeriesDefinition.ShowItemLabels = true;  
        }  
 
        private List<Stock> GetStocks()  
        {  
            List<Stock> lstStock = new List<Stock>();  
 
            for (int i = 0; i < 1000; i=i+100)  
            {  
                Stock s = new Stock();  
                s.Name = "Stock" + i;  
                s.Open = i + 100;  
                s.Low = i;  
                Random r = new Random(i);  
                r.NextDouble();  
                s.Close = r.Next(100,150) + i;  
                s.High = s.Close + i;  
                lstStock.Add(s);  
            }  
 
            return lstStock;  
        }  
 
          
 
    }  
 
    public class Stock  
    {  
 
        public string Name { getset; }  
        public double Open { getset; }  
        public double Close { getset; }  
        public double High { getset; }  
        public double Low { getset; }  
 
    } 

Stick chart is also shown (Plz See attachment).

Issue:

I have set telerikChart.DefaultSeriesDefinition.ShowItemLabels = true;  
so that to see the Item Label, but stick chart is showing 0 as highlighted in the screenshot. Is there way to see open,Close,Low.high value of the stick as a item label?


Can you please provide me good sample for the same. also provide pointer to doc that explains the Stick chart.

Ves
Telerik team
 answered on 25 Jun 2010
1 answer
672 views
Hello,

Is it possible to prevent drag operation when an user is using a GridSplitter to resize column/row ?

For example :



        <telerik:RadTreeView IsDragDropEnabled="True" ItemTemplate="{StaticResource TreeItemTemplate}">  
            <telerik:RadTreeView.ItemContainerStyle> 
                <Style TargetType="{x:Type telerik:RadTreeViewItem}">  
                    <Setter Property="HorizontalContentAlignment" Value="Stretch"/>  
                </Style> 
            </telerik:RadTreeView.ItemContainerStyle> 
            <telerik:RadTreeView.Items> 
                <Control Name="control1" Tag="Some text for control1" /> 
                <Control Name="control2" Tag="Some text for control2" /> 
            </telerik:RadTreeView.Items> 
        </telerik:RadTreeView> 
 
            <DataTemplate x:Key="TreeItemTemplate">  
                <Border BorderThickness="1" BorderBrush="LightGray" Margin="2" CornerRadius="5">  
                    <Grid> 
                        <Grid.ColumnDefinitions> 
                            <ColumnDefinition Width="Auto"/>  
                            <ColumnDefinition Width="*"/>  
                        </Grid.ColumnDefinitions> 
                        <TextBlock Grid.Column="0" Text="{Binding Name}" Margin="3,0,10,0"/>  
                        <GridSplitter Grid.Column="0" Width="1" Background="LightGray" ResizeDirection="Columns"/>  
                        <TextBlock Grid.Column="1" Text="{Binding Tag}" Margin="3,0,0,0"/>  
                    </Grid> 
                </Border> 
            </DataTemplate> 
 

Is there any solution ? I tried t define  dragDrop:RadDragAndDropManager.AllowDrag="False" on GridSplitter but this doesn't work.

I have the same problem using RadDragDropManager in a templated list (Some draggable items contain Slider).

Thanks,
Guillaume.
GuillaumeR
Top achievements
Rank 1
 answered on 25 Jun 2010
3 answers
614 views
I've done some searching, but I didn't see this issue anywhere.  Please forgive me if I'm duplicating.  There are two issues but they appear related.

Issue #1

I have a RadOutlookBar that is bound to a list of items.  Each of the items contains a list which is bound to a grid.  The grid is in a template that defines the RadOutlookBar's content.  Everything binds fine, but when I select a different RadOutlookBarItem, the grid refreshes, and will throw an exception:

Invalid property or field - '[FieldName]' for type: Object  


In this case, it only happens for one field, and only if I specify the DataFormatString. 

DataFormatString="{}{0:dd/MM/yyyy}" 

As you can see, this field is DateTime type.  If I step through the exceptions, the field will load properly.

Issue #2

This issue is very similar to the above.  We have a RadTabControl that is bound to a list.  The list items also contain lists which are bound to a template that contains a grid.  In this case, the items are different types and so the grids themselves are defined in different DataTemplates targeting their specific DataTypes.  Initially, everything loads just fine, but when you select a different tab, an exception with the same message as issue #1 will be thrown for each column that was defined in the originally selected tab.  This time though, the type is the type of item listed in the newly selected tab's grid.

Invalid property or field - '[FieldName from previous]' for type: [Row data type for selected] 

Again, after stepping through the exceptions, the grid loads just fine.

One tip for reproducing the exceptions if they are not being caught (the code is just throwing exceptions away):
Go to Debug -> Exceptions.. 
Tick the "Thrown" checkbox next to "Common Language Runtime Exceptions".




Vlad
Telerik team
 answered on 25 Jun 2010
1 answer
133 views
Hi,

    When open too many tabs in the docking area, the tabs tend to be very small and hard to find, is there any method to create a button at coner and when clicked  it opens a drop down list of all opened tabs?
 

bingwei
Top achievements
Rank 1
 answered on 25 Jun 2010
2 answers
116 views

Hi there,

I just like my Drop working if the target is inside the same ListBoxItem, not across ListBoxItem.

For instatnce, I put the the telerik's FirstLook example(aa1:eample) in ListBox:
<ListBox Grid.Row="1">
<ListBoxItem Height="250"> <aa1:Example></aa1:Example></ListBoxItem>

<ListBoxItem> <aa1:Example></aa1:Example>
</ListBoxItem>

</ListBox>

The control will show 2 times, I can drag from ListBoxItem1 and drop to ListBoxItem2.  What I need is drag from ListBoxItem1 and drop the other side of ListBoxItem1, avoid dropping to different ListBoxItem. Is any way to fix that?

Thanks!

Amy

Amy
Top achievements
Rank 1
 answered on 24 Jun 2010
3 answers
120 views

I'm using endless scrolling.  (based on this code: "Endless scrolling of 2mil. records" that is updated for Q2010 here: http://www.telerik.com/ClientsFiles/159249_wpfapplication1.zip)

The problem is I can't get data from selected row. I see the data in debugger (var row = radGrid.SelectedItem;) but don't know How to get.

I can change the "QueryableCollectionView" from:
orderby s.artist, s.title 
select new { s.artist, s.title, s.id}); 


to:
orderby s.artist, s.title 
select s); 


Then I can get my class from Datacontex, but then the grid scroll to top evrytime it fill ut with new data, and I don't like that...






f__AnonymousType
Vlad
Telerik team
 answered on 24 Jun 2010
2 answers
84 views
Hi there,

We are using the GridViewComboBoxColumn to display a set of times available for the user to pick from in a given day of the week.

The client would like to choose from values like "0759", "1700", "1130", etc.  Basically it's just a 4 digit text value.  Because of their screen size requirements we need to make the column width as small as possible.

The problem I'm having is that when the user attempts to edit the column, when the cell changes to a Textbox with the arrow, the last digit gets clipped.  This poses a problem because the user likes to Tab through the cells making changes and they cannot see the true value because the last digit is clipped.

You can see an example in this screenshot.

it appears like there is plenty of room next to the arrow pointing down, but there appears to be some excessive left-padding on that arrow that is overlapping the text.

Is there anyway I can adjust this?
Rick Glos
Top achievements
Rank 1
 answered on 24 Jun 2010
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
PersistenceFramework
DataPager
Styling
TimeBar
OutlookBar
TransitionControl
FileDialogs
Book
ToolBar
ColorPicker
TimePicker
MultiColumnComboBox
SyntaxEditor
VirtualGrid
Wizard
ExpressionEditor
NavigationView (Hamburger Menu)
WatermarkTextBox
DesktopAlert
BarCode
SpellChecker
DataServiceDataSource
EntityFrameworkDataSource
RadialMenu
ChartView3D
Data Virtualization
BreadCrumb
ProgressBar
Sparkline
LayoutControl
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
PasswordBox
Rating
SplashScreen
Accessibility
Callout
CollectionNavigator
Localization
AutoSuggestBox
Security
VirtualKeyboard
HighlightTextBlock
TouchManager
StepProgressBar
Badge
OfficeNavigationBar
ExpressionParser
CircularProgressBar
SvgImage
PipsPager
SlideView
AI Coding Assistant
+? more
Top users last month
Top achievements
Rank 1
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ivory
Top achievements
Rank 1
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
YF
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Top achievements
Rank 1
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ivory
Top achievements
Rank 1
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
YF
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?