Telerik Forums
UI for WPF Forum
2 answers
111 views
Hi,

I would like to draw a bar chart and set min and max values for each bar. How to accomplish that?
Martinelli
Top achievements
Rank 1
 answered on 30 Jan 2012
2 answers
88 views
Hello,
I've a combobox defined as

    <telerik:RadComboBox Grid.Row="0" IsEditable="true" SelectedItem="{Binding SelectedDateMode=TwoWay}"
                             x:Name="ComboBox" Height="30" Width="150" ItemsSource="{Binding Collection, Mode=OneWay}"
                             ItemTemplateSelector="{StaticResource itemTemplateSelector}" OpenDropDownOnFocus="True" />

and the template I'm going to use is

 <DataTemplate x:Key="datetimeDataTemplateSelector">
                <TextBlock Text="{Binding Data}"/>
            </DataTemplate>

it's bound to an object of type

   public class TestObject : INotifyPropertyChanged
    {
        public bool IsGeneric { get; set; }

        public DateTime? Data { get; set; }

        public event PropertyChangedEventHandler PropertyChanged;

        public void NotifyPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }
and when the dropdown is open I got the data shown.. when I select an Item I got for the itemtemplate RadControlsWpfApp2.TestObject

Since I cannot specify a DisplayMember how can I tell to show the Data value?
Thanks
Michele
Top achievements
Rank 2
 answered on 30 Jan 2012
4 answers
118 views
I use the GridView in a fashion similar to your example in http://www.telerik.com/help/wpf/gridview-managing-data-add-new-entries.html:
private void radGridView_RowEditEnded( object sender, GridViewRowEditEndedEventArgs e )
{
    if ( e.EditAction == GridViewEditAction.Cancel )
    {
        return;
    }
    if ( e.EditOperationType == GridViewEditOperationType.Insert )
    {
        //Add the new entry to the data base.
        DBUtility.AddEmployee( e.NewData );
    }
}

My "DBUtility.AddEmployee" may return an exception due to a database constraint (e.g. duplicate key). Is there a suggested way to handle this? Any special event?
I would like the result to look approximately the same way as if I was using RowValidating and set the IsValid property to false.

Thanks.
Nedyalko Nikolov
Telerik team
 answered on 30 Jan 2012
3 answers
537 views
Hello.
I am using Telerik 2011.2 in a MVVM application.
What I want to do is round the edges of the entire header row, I have been able to fake it thus far by setting the corner radius for the upper right corner on the GridViewHeaderRow, and templating the left most column's HeaderCellStyle. The problem being that the user cannot rearrange the columns or else it looks very bad. I would like to set the corner radius for the upper right and left corners "above" the individual cells so that it works no matter the order or content of the individual cells. Don't know the property I am looking for. I have tried finding it in expression blend but cannot seem to get the right style in the editor. If you could give me a copy of the default style involved I can modify it is needed, thank you.

Eli
Vanya Pavlova
Telerik team
 answered on 30 Jan 2012
1 answer
110 views
Hello!

I have a problem with updating of layout the ScheduleView control.

i have a code:

    <Grid>
        <DockPanel LastChildFill="True">
            <StackPanel Orientation="Horizontal" DockPanel.Dock="Top" Margin="10" Height="25">
                <Button Content="Change" Width="100" Click="Button_Click"></Button>
            </StackPanel>
            <telerik:RadScheduleView Name="schedule">
                <telerik:RadScheduleView.ActiveViewDefinition>
                    <scheduleView:TimelineViewDefinition DayStartTime="10:00:00" DayEndTime="20:00:00" Orientation="Vertical" VisibleDays="1" MinTimeRulerExtent="100"></scheduleView:TimelineViewDefinition>
                </telerik:RadScheduleView.ActiveViewDefinition>
            </telerik:RadScheduleView>
        </DockPanel>
    </Grid>

and simple handler of click the 'Change' button:


private void Button_Click(object sender, RoutedEventArgs e)
        {
            schedule.ActiveViewDefinition.DayStartTime = schedule.ActiveViewDefinition.DayStartTime.Add(new TimeSpan(1, 0, 0));
        }


when i am trying to change the DayStartTime/DayEndTime value the height of ScheduleView displays wrong. Height of ScheduleView  just cuts. wihtout any updating of inner grid the ScheduleView control.

Regards,
Stas.
stas
Top achievements
Rank 1
 answered on 30 Jan 2012
5 answers
323 views
Trying to use zoom and scroll MVVM way. ZoomInCommand and ZoomOutCommand get fired however modified MinZoomRange, RangeEnd, RangeStart but zoom is not working. Can you suggest any alternative ?


 <charting:ChartArea Grid.Row="0" Grid.RowSpan="2"
                                       x:Name="chartArea"
                                       Legend="{Binding ElementName=legend}"
                                       EnableAnimations="False"
                                       SmartLabelsEnabled="True"
                                       Padding="5,10,20,10">
 
 
 
                            <charting:ChartArea.ZoomScrollSettingsX>
                                <charting:ZoomScrollSettings ScrollMode="ScrollAndZoom" 
                                                                MinZoomRange="{Binding MinZoomRange, Mode=TwoWay}" 
                                                                RangeEnd ="{Binding RangeEnd, Mode=TwoWay}"
                                                                RangeStart ="{Binding RangeStart, Mode=TwoWay}"/>
                            </charting:ChartArea.ZoomScrollSettingsX>
                            <charting:ChartArea.AxisY>
                                <charting:AxisY AutoRange="True" />
                            </charting:ChartArea.AxisY>
                            <charting:ChartArea.AxisX>
                                <charting:AxisX DefaultLabelFormat="MM.dd&#x0a;yyyy" StepLabelLevelCount="2" />
                            </charting:ChartArea.AxisX>
 
 
 
                        </charting:ChartArea>
 
                        <StackPanel HorizontalAlignment="Right" Orientation="Horizontal" Margin="0,10,15,5">
                            <telerik:RadButton Command="{Binding ZoomInCommand}" Margin="5,0" Width="20" Height="20" CornerRadius="16" BorderBrush="{StaticResource StrongBrush}">
                                <Path Stretch="Fill" Width="8" Height="8" HorizontalAlignment="Center" VerticalAlignment="Center" Stroke="{StaticResource StrongBrush}"/>
                            </telerik:RadButton>
                            <telerik:RadButton Command="{Binding ZoomOutCommand}" Margin="5,0" Width="20" Height="20" CornerRadius="16" BorderBrush="{StaticResource StrongBrush}">
                                <Path Stretch="Fill" Width="8" Height="8" HorizontalAlignment="Center" VerticalAlignment="Center" Stroke="{StaticResource StrongBrush}"/>
                            </telerik:RadButton>
                        </StackPanel>

View Model
        #region zoom
    
 
        ICommand _zoomInCommand;
        public ICommand ZoomInCommand
        {
            get
            {
                if (_zoomInCommand == null)
                {
                    _zoomInCommand = new DelegateCommand(ZoomIn, CanZoomIn);
                }
                return _zoomInCommand;
            }
        }
 
        ICommand _zoomOutCommand;
        public ICommand ZoomOutCommand
        {
            get
            {
                if (_zoomOutCommand == null)
                {
                    _zoomOutCommand = new DelegateCommand(ZoomOut, CanZoomOut);
                }
                return _zoomOutCommand;
            }
        }
 
 
 
		private double _MaxZoomRange;
		public double MaxZoomRange
		{
			get { return _MaxZoomRange;}
			set
			{
				{
					_MaxZoomRange = value;
					OnPropertyChanged(()=>this.MaxZoomRange);
				}
			}
		} 
 
        
		private double _Range;
		public double Range
		{
			get { return _Range;}
			set
			{
				{
					_Range = value;
					OnPropertyChanged(()=>this.Range);
				}
			}
		} 
    
 
		private double _RangeEnd;
		public double RangeEnd
		{
			get { return _RangeEnd;}
			set
			{
				{
					_RangeEnd = value;
					OnPropertyChanged(()=>this.RangeEnd);
				}
			}
		} 
        
    
		private double _RangeStart;
		public double RangeStart
		{
			get { return _RangeStart;}
			set
			{
				{
					_RangeStart = value;
					OnPropertyChanged(()=>this.RangeStart);
				}
			}
		} 
    
        
		private double _MinZoomRange;
		public double MinZoomRange
		{
			get { return _MinZoomRange;}
			set
			{
				{
					_MinZoomRange = value;
					OnPropertyChanged(()=>this.MinZoomRange);
				}
			}
		} 
    
        //
        // Summary:
        //     Gets or sets the scroll mode.
        
        public ScrollMode ScrollMode { getset; }
        //
        // Summary:
        //     Gets or sets the slider selection end.
        
        public double SliderSelectionEnd { getset; }
        //
        // Summary:
        //     Gets or sets the slider selection start.
        
        public double SliderSelectionStart { getset; }
        
 
        public void ZoomIn(object parameter)
        {
 
            double zoomCenter = RangeStart + (Range / 2);
            double newRange = Math.Max(MinZoomRange, Range) / 2;
            RangeStart = Math.Max(0, zoomCenter - (newRange / 2));
            RangeEnd = Math.Min(1, zoomCenter + (newRange / 2));
 
 
            ((DelegateCommand)_zoomInCommand).InvalidateCanExecute();
            ((DelegateCommand)_zoomOutCommand).InvalidateCanExecute();
        }
 
        public bool CanZoomIn(object parameter)
        {
 
            return Range > MinZoomRange;
        }
 
        public void ZoomOut(object parameter)
        {
 
            double zoomCenter = RangeStart + (Range / 2);
            double newRange = Math.Min(1, Range) * 2;
 
            if (zoomCenter + (newRange / 2> 1)
                zoomCenter = 1 - (newRange / 2);
            else if (zoomCenter - (newRange / 2< 0)
                zoomCenter = newRange / 2;
 
            RangeStart = Math.Max(0, zoomCenter - newRange / 2);
            RangeEnd = Math.Min(1, zoomCenter + newRange / 2);
 
 
 
            ((DelegateCommand)_zoomInCommand).InvalidateCanExecute();
            ((DelegateCommand)_zoomOutCommand).InvalidateCanExecute();
        }
 
        public bool CanZoomOut(object parameter)
        {
 
            return Range < 1d;
        }
        #endregion
        public ViewModel()
        {
            MinZoomRange = 0.005;
            Range = 1.0;
            RangeEnd = 1.0;
            RangeStart = 0.0;
        }
Yavor
Telerik team
 answered on 30 Jan 2012
2 answers
122 views
I'm getting the following error whenever I click on an appointment on the schedule view. I can drag/drop appointments onto the schedule view but actually clicking on an appointment will give me the following error. Also note that this isn't just when I'm debugging my own WPF app in Visual Studio, this happens when I try to click on an appointment in the WPF Controls Example application aswell. Looks like it's trying to find a file on the C:\ drive that I can confirm is not there.

Generic types cannot be marshaled to COM interface pointers.

Locating source for 'c:\Builds\WPF_Scrum\Release_WPF\Sources\Development\Controls\ScheduleView\ScheduleView\Controls\AppointmentItem.cs'. Checksum: MD5 {87 50 ae 34 9e 6c a1 bb c7 7a 37 31 e6 5c 9e c8}
The file 'c:\Builds\WPF_Scrum\Release_WPF\Sources\Development\Controls\ScheduleView\ScheduleView\Controls\AppointmentItem.cs' does not exist.
Looking in script documents for 'c:\Builds\WPF_Scrum\Release_WPF\Sources\Development\Controls\ScheduleView\ScheduleView\Controls\AppointmentItem.cs'...
Looking in the projects for 'c:\Builds\WPF_Scrum\Release_WPF\Sources\Development\Controls\ScheduleView\ScheduleView\Controls\AppointmentItem.cs'.
The file was not found in a project.
Looking in directory 'c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\crt\src\'...
Looking in directory 'c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\src\mfc\'...
Looking in directory 'c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\src\atl\'...
Looking in directory 'c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\include\'...
The debug source files settings for the active solution indicate that the debugger will not ask the user to find the file: c:\Builds\WPF_Scrum\Release_WPF\Sources\Development\Controls\ScheduleView\ScheduleView\Controls\AppointmentItem.cs.
The debugger could not locate the source file 'c:\Builds\WPF_Scrum\Release_WPF\Sources\Development\Controls\ScheduleView\ScheduleView\Controls\AppointmentItem.cs'.

Daniel
Top achievements
Rank 1
 answered on 30 Jan 2012
1 answer
145 views
Hi Folks,
When I use entryfield validation by exception, controls paint a red border around itself on error.
How can I set this border from outside ?
(I.e. an outer "check function" gets called from somewhere and wants to set the red "error state" on an entryfield)
Is there something like radTextBox1.SetErrorState ???

Best regards
Torsten
Maya
Telerik team
 answered on 30 Jan 2012
2 answers
288 views
Hi.

I'm having a problem with the following code:
<telerik:RadRibbonDropDownButton.DropDownContent>
    <StackPanel >
        <StackPanel Orientation="Horizontal" x:Name="LayoutRoot">
            <ListBox Name="ListBox" ItemsSource="{Binding Path=Columns, ElementName=TableGrid}">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <CheckBox Content="{Binding Header}"
                            IsChecked="{Binding IsVisible, Mode=TwoWay}" />
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
            <telerik:RadGridView Name="TableGrid" ItemsSource="{Binding Units}" ShowGroupPanel="False" />
        </StackPanel>
    </StackPanel>
</telerik:RadRibbonDropDownButton.DropDownContent>
This is the "Showing and hiding radgrid columns outside the radgrid" example from the Telerik website, in a dropdowncontent.  When I run this and set the datacontext, "TableGrid" shows data properly but "ListBox" does not show the column headers.  If I take the "LayoutRoot" stackpanel up a level, out of the radribbonbutton and into the radribbongroup driectly, it works fine ("ListBox" contains the "TableGrid" headers.)  Poking around I've read that that the dropdowncontext doesn't share the same visual tree as the parent, but I would think I could bind controls from within the dropdowncontext.  Can you point me in the right direction to resolve this please?

Thanks,
MR
Mike
Top achievements
Rank 1
 answered on 30 Jan 2012
0 answers
218 views

I have used MVVm pattern in my application having three views.I wanted display log messages(status,error etc) in 1st window( in listbox ).I have created singleton class(loghelper) with function AddLog(),which i am calling whever i wanna update log msg & to write to log file also.so whenver this method gets called ,it triggers event(in loghelper class) and the eventhandler in respective view model gets called and there it adds log messages to Source(ObservableCollection which is bound to list box).
Now the problem is eventhough log message is added to collection for each log msg ,message is not updating synchronously in list box.View looks like freezing for a minute and all messages updates at a time.
I am not using multithreading here.
plz Let me know what causes this problem?

Deepak
Top achievements
Rank 1
 asked on 28 Jan 2012
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?