Telerik Forums
UI for WPF Forum
4 answers
807 views

We have a RadGridView with 2 columns.
When we edit a cell or when we are adding a new row, we want to loop through the rows cell[1] to check for duplicates.
We want to do this in...

private void TheGridCellValidating(object sender, GridViewCellValidatingEventArgs e).

We try things like this...

            var grid = (e.Row).GridViewDataControl;
            string value = e.NewValue.ToString();
           
            var rows = grid.ChildrenOfType<GridViewRow>();

            foreach (var row in rows)
            {
                if (row == null) continue;
                if (row.Cells == null) continue;
                if (row.Cells[1] != null)
                {
                    var s = row.Cells[0]......
                    ...
                    ....
                }
            }
But... it won't work.
How can we iterate on the rows and check for duplicates?

Milan
Telerik team
 answered on 12 Jul 2010
1 answer
100 views
Say I have a DataContext with:
ObservableCollection<Toto> m_files = new ObservableCollection<Toto>();
public ObservableCollection<Toto> Filenames
{
    get
    {
        return m_files;
    }
}

For some reason, this code:
<map:InformationLayer ItemsSource="{Binding Filenames}">
    <map:InformationLayer.ItemTemplate>
        <DataTemplate>
            <Canvas map:MapLayer.Location="5, 5" Width="100" Height="100" Background="AliceBlue">
                <TextBlock Text="{Binding}"/>
            </Canvas>
        </DataTemplate>
    </map:InformationLayer.ItemTemplate>
</map:InformationLayer>

crashes with this exception:
System.FormatException was unhandled
  Message=Input string was not in a correct format.
  Source=Telerik.Windows.Controls.DataVisualization
  StackTrace:
       at Telerik.Windows.Controls.Map.Location.Parse(String source) in c:\Builds\WPF_Scrum\Release_WPF_2010_Q1_SP2\Sources\Development\Controls\DataVisualization\Map\Location.cs:line 200
       at Telerik.Windows.Controls.Map.LocationConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value) in c:\Builds\WPF_Scrum\Release_WPF_2010_Q1_SP2\Sources\Development\Controls\DataVisualization\Map\LocationConverter.cs:line 40
       at System.ComponentModel.TypeConverter.ConvertFrom(Object value)
       at Telerik.Windows.Controls.Map.InformationLayer.GetLocationFromItem(Object item) in c:\Builds\WPF_Scrum\Release_WPF_2010_Q1_SP2\Sources\Development\Controls\DataVisualization\Map\Layers\InformationLayer.cs:line 1214
       at Telerik.Windows.Controls.Map.InformationLayer.PrepareContainerForItemOverride(DependencyObject element, Object item) in c:\Builds\WPF_Scrum\Release_WPF_2010_Q1_SP2\Sources\Development\Controls\DataVisualization\Map\Layers\InformationLayer.cs:line 449
       at System.Windows.Controls.ItemsControl.MS.Internal.Controls.IGeneratorHost.PrepareItemContainer(DependencyObject container, Object item)
       at System.Windows.Controls.ItemContainerGenerator.System.Windows.Controls.Primitives.IItemContainerGenerator.PrepareItemContainer(DependencyObject container)
       at System.Windows.Controls.Panel.reGenerateChildren()
       at System.Windows.Controls.Panel.OnItemsChangedInternal(Object sender, ItemsChangedEventArgs args)
       at System.Windows.Controls.Panel.OnItemsChanged(Object sender, ItemsChangedEventArgs args)
       at System.Windows.Controls.ItemContainerGenerator.OnRefresh()
       at System.Windows.Controls.ItemContainerGenerator.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
       at System.Windows.Controls.ItemContainerGenerator.System.Windows.IWeakEventListener.ReceiveWeakEvent(Type managerType, Object sender, EventArgs e)
       at System.Windows.WeakEventManager.DeliverEventToList(Object sender, EventArgs args, ListenerList list)
       at System.Windows.WeakEventManager.DeliverEvent(Object sender, EventArgs args)
       at System.Collections.Specialized.CollectionChangedEventManager.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
       at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
       at System.Windows.Data.CollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args)
       at System.Windows.Controls.ItemCollection.System.Windows.IWeakEventListener.ReceiveWeakEvent(Type managerType, Object sender, EventArgs e)
       at System.Windows.WeakEventManager.DeliverEventToList(Object sender, EventArgs args, ListenerList list)
       at System.Windows.WeakEventManager.DeliverEvent(Object sender, EventArgs args)
       at System.Collections.Specialized.CollectionChangedEventManager.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args)
       at System.Windows.Data.CollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args)
       at System.Windows.Data.ListCollectionView.RefreshOverride()
       at System.Windows.Data.CollectionView.RefreshInternal()
       at System.Windows.Data.CollectionView.Refresh()
       at System.Windows.Data.CollectionView.EndDefer()
       at System.Windows.Data.CollectionView.DeferHelper.Dispose()
       at System.Windows.Controls.ItemCollection.SetCollectionView(CollectionView view)
       at System.Windows.Controls.ItemCollection.SetItemsSource(IEnumerable value)
       at System.Windows.Controls.ItemsControl.OnItemsSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
       at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
       at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
       at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
       at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, OperationType operationType)
       at System.Windows.DependencyObject.InvalidateProperty(DependencyProperty dp)
       at System.Windows.Data.BindingExpression.Invalidate(Boolean isASubPropertyChange)
       at System.Windows.Data.BindingExpression.TransferValue(Object newValue, Boolean isASubPropertyChange)
       at System.Windows.Data.BindingExpression.Activate(Object item)
       at System.Windows.Data.BindingExpression.AttachToContext(AttachAttempt attempt)
       at System.Windows.Data.BindingExpression.MS.Internal.Data.IDataBindEngineClient.AttachToContext(Boolean lastChance)
       at MS.Internal.Data.DataBindEngine.Task.Run(Boolean lastChance)
       at MS.Internal.Data.DataBindEngine.Run(Object arg)
       at MS.Internal.Data.DataBindEngine.OnLayoutUpdated(Object sender, EventArgs e)
       at System.Windows.ContextLayoutManager.fireLayoutUpdateEvent()
       at System.Windows.ContextLayoutManager.UpdateLayout()
       at System.Windows.UIElement.UpdateLayout()
       at System.Windows.Interop.HwndSource.SetLayoutSize()
       at System.Windows.Interop.HwndSource.set_RootVisualInternal(Visual value)
       at System.Windows.Interop.HwndSource.set_RootVisual(Visual value)
       at System.Windows.Window.SetRootVisual()
       at System.Windows.Window.SetupInitialState(Double requestedTop, Double requestedLeft, Double requestedWidth, Double requestedHeight)
       at System.Windows.Window.CreateSourceWindowImpl()
       at System.Windows.Window.SafeCreateWindow()
       at System.Windows.Window.ShowHelper(Object booleanBox)
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
       at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
       at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, 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)
       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, Boolean isSingleParameter)
       at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
       at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
       at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter)
       at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)
       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 WpfApplication1.App.Main() in C:\Users\frederic.souchu\documents\visual studio 2010\Projects\WpfMap\WpfApplication1\obj\x86\Release\App.g.cs:line 0
       at System.AppDomain._nExecuteAssembly(Assembly 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)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: System.FormatException
       Message=Input string was not in a correct format.
       Source=Telerik.Windows.Controls.DataVisualization
       StackTrace:
            at Telerik.Windows.Controls.Map.Location.Parse(String source) in c:\Builds\WPF_Scrum\Release_WPF_2010_Q1_SP2\Sources\Development\Controls\DataVisualization\Map\Location.cs:line 185
       InnerException:



Note that replacing the <string> element by any sort of class just works fine!
Regards
Frederic

Andrey
Telerik team
 answered on 12 Jul 2010
1 answer
199 views
Is it possible to hide the drop-down button from the RadTimePicker?
Dani
Telerik team
 answered on 12 Jul 2010
4 answers
138 views
I'm new to WPF and to the Carousel as well, but taking what little examples there are for this control just isn't working for me. Even taking the exact code from your documentation and applying it makes my Carousel disappear.

When trying to view the Style in Expression Blend 4, I get an error "Property values set when no trigger is active". 

The code I have is very simple:

<telerik:RadCarousel x:Name="carousel"
            <Image Source="Images/Puck/1.jpg" Width="200" Height="200" Stretch="Fill" /> 
            <Image Source="Images/Puck/4.jpg" Width="200" Height="200" Stretch="Fill" /> 
            <Image Source="Images/Puck/5.jpg" Width="200" Height="200" Stretch="Fill" /> 
            <Image Source="Images/Puck/6.jpg" Width="200" Height="200" Stretch="Fill" /> 
            <Image Source="Images/Puck/7.jpg" Width="200" Height="200" Stretch="Fill" /> 
            <Image Source="Images/Puck/9.jpg" Width="200" Height="200" Stretch="Fill" /> 
            <Image Source="Images/Puck/10.jpg" Width="200" Height="200" Stretch="Fill" /> 
            <Image Source="Images/Puck/11.jpg" Width="200" Height="200" Stretch="Fill" /> 
        </telerik:RadCarousel> 
        <Grid.Resources> 
            <Style TargetType="{x:Type telerik:CarouselItem}"
                <Setter Property="Template"
                    <Setter.Value> 
                        <ControlTemplate TargetType="{x:Type telerik:CarouselItem}"
                            <Border x:Name="border"
                                <VisualStateManager.VisualStateGroups> 
                                    <VisualStateGroup x:Name="ValidationStates"
                                        <VisualState x:Name="Valid"/> 
                                        <VisualState x:Name="InvalidFocused"/> 
                                        <VisualState x:Name="InvalidUnfocused"/> 
                                    </VisualStateGroup> 
                                </VisualStateManager.VisualStateGroups> 
                                <Border x:Name="CarouselItemMainBorder" 
                                    ClipToBounds="False" RenderTransformOrigin="0.5, 1" 
                                    Opacity="{Binding ReflectionSettings.Opacity, RelativeSource={RelativeSource TemplatedParent}}" 
                                    Visibility="{Binding ReflectionSettings.Visibility, RelativeSource={RelativeSource TemplatedParent}}" 
                                    BorderBrush="{x:Null}" BorderThickness="1,1,1,1" CornerRadius="0" SnapsToDevicePixels="True" Margin="0,0,-10,-35" MouseEnter="MouseEnterTest"
                                    <Border.Background> 
                                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"
                                            <GradientStop Color="#FFC1DCFF" Offset="0"/> 
                                            <GradientStop Color="#FF7EB8F8" Offset="1"/> 
                                        </LinearGradientBrush> 
                                    </Border.Background> 
                                </Border> 
                            </Border> 
                        </ControlTemplate> 
                    </Setter.Value> 
                </Setter> 
            </Style> 
        </Grid.Resources> 

x
Top achievements
Rank 1
 answered on 10 Jul 2010
5 answers
276 views
I followed this link http://www.telerik.com/help/wpf/radtabcontrol-populating-binding-to-collection.html to bind a collection to my tab control. The content is displaying properly but the header is not. My header is still displaying "MiddleLayer.SalesPerson" even though I assigned "Name" to DisplayMemberpath. My code is as below

    <UserControl.Resources>
        <DataTemplate x:Key="salesTemplate">
            <ctrls:AccountSalesPersonUserControl DataContext="{Binding}"></ctrls:AccountSalesPersonUserControl>
        </DataTemplate>
    </UserControl.Resources>

 <telerikPresent:RadTabControl x:Name="SalesPersonTab" ItemsSource="{Binding Path=SelectedItem.SalesPersons, Mode=OneWay}"
                   DisplayMemberPath="Name" ContentTemplate="{StaticResource salesTemplate}" />




Alex Wu
Top achievements
Rank 1
 answered on 10 Jul 2010
2 answers
421 views
Hello All,

We are in the process of converting the plain old WPF TabControl with the RadTabControl.  We have a need to get the last tab that was selected before the user clicked a new tab.

Using the WPF TabControl, in the EventArgs, there was an AddedItems and RemovedItems property.  In the RadTabControl, these do not exist.

Is there a way to get the user's last selected TabItem using this handler?

Thanks,
Chris
Chris Andrews
Top achievements
Rank 1
 answered on 09 Jul 2010
7 answers
244 views
Hello everybody

After doing researches in all available source I still can not accomplish this probably trivial task. I would like to read the values of various cells of the row which is selected. The sample I found in this forum deals with a business object (Person). I'd expected something like:

myValue = gridview.selectedRow.Columns("NameOfThisColumn")

Thanks for your help in advance

Michael Lutz
BITsoft
Vlad
Telerik team
 answered on 09 Jul 2010
7 answers
215 views
Hello Everybody

I would like to be able to create custom groupings that allow users to group by a range of values rather than by a specific value of a particular member.  For example, if there is a "severity" column that has integer values from 0-199, I'd like to be able to create 2 groups of severity 0-99 and 100-199 instead of the default of 200 groups, one for severity 1, one for severity 2, etc.

I've hunted through the docs and it looks like I may be able to extend from Telerik.Windows.Data.GroupDescriptor to achieve my goal, but the documentation on the subject is not very helpful.  Can anyone explain how the GroupDescriptor class creates a grouping, or even better, provide code examples of how its done?

Thanks,
Tom
Pavel Pavlov
Telerik team
 answered on 09 Jul 2010
3 answers
617 views
Hello,

How can I get the location (latitude and longitude coordinates) for the point beneath the mouse cursor?

Thank you.
Andrey
Telerik team
 answered on 09 Jul 2010
3 answers
119 views
Hi,

I'm testing out this library and I'm getting the following error:
No method 'Average' on type 'System.Linq.Enumerable' is compatible with the supplied arguments.

I'm doing a very simple test. Here is the relevant code:

public class Data     
{     
    public UInt32 XValue { getset; }     
    public double YValue { getset; }     
}     
    
List<Data> m_Data; // This is initialized with data.     
    
// Then, when setting up the chart...     
    
SeriesMapping seriesMapping = new SeriesMapping();     
LineSeriesDefinition lineDefinition = new LineSeriesDefinition();     
lineDefinition.ShowItemLabels = false;     
seriesMapping.SeriesDefinition = lineDefinition;     
seriesMapping.ItemMappings.Add(new ItemMapping("XValue", DataPointMember.XValue));  
seriesMapping.ItemMappings.Add(new ItemMapping("YValue", DataPointMember.YValue));     
MyChart.SeriesMappings.Add(seriesMapping);     
    
// Then I set my data     
MyChart.ItemSource = m_Data; 

When m_Data has more then 397 elements it throws that error. Before that number it looks pretty.

Any help will be greatly appreciated.
- Luis
Ves
Telerik team
 answered on 09 Jul 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?