Telerik Forums
UI for WPF Forum
1 answer
184 views

My MVVM app loads user defined polygons from a DB and then databinds the information layer (after the map is initialised, as suggested in the documentation).

When I explicitly declare the colours in the data template the binding works perfectly. But when I data bind the colours (using a converter to convert them to a SolidColorBrush) it doesn't display the shapes at all.

Here's the XAML...

<
telerik:RadMap x:Name="mapControl" Center="53.54245,-2.298817" ZoomLevel="7">
    <telerik:InformationLayer x:Name="shapeLayer" Visibility="Visible">
        <telerik:InformationLayer.ItemTemplate>
            <DataTemplate>
                <telerik:MapPolyline Fill="{Binding Fill, Converter={StaticResource converter}}" Opacity="0.5"  Points="{Binding Points}" Stroke="{Binding Stroke, Converter={StaticResource converter}}" StrokeThickness="2" />
            </DataTemplate>
        </telerik:InformationLayer.ItemTemplate>
    </telerik:InformationLayer>
</telerik:RadMap>

Here's the view model that I'm using for each shape.

    public class ShapeViewModel : ViewModelBase
    {
        private LocationCollection _points;
        private Color _stroke;
        private Color _fill;
 
        public LocationCollection Points
        {
            get { return _points; }
            set
            {
                if (_points != value)
                {
                    _points = value;
                    OnPropertyChanged(() => Points);
                }
            }
        }
 
        public Color Fill
        {
            get { return _fill; }
            set
            {
                if (_fill != value)
                {
                    _fill = value;
                    OnPropertyChanged(() => Fill);
                }
            }
        }
 
        public Color Stroke
        {
            get { return _stroke; }
            set
            {
                if (_stroke != value)
                {
                    _stroke = value;
                    OnPropertyChanged(() => Stroke);
                }
            }
        }
    }

I don't see any binding errors in my output window.

Thanks
Ben

ben crinion
Top achievements
Rank 1
 answered on 23 Aug 2013
3 answers
67 views
We have a requirement to display, along with other columns, a cumulative value column within the RadGridView.  To do this we attach a behavior to the RadGridView.  The relevant code from the behavior is this:

protected override void OnAttached()
       {
           AssociatedObject.DataLoaded += AssociatedObject_DataLoaded;
           AssociatedObject.RowEditEnded += AssociatedObject_RowEditEnded;
           base.OnAttached();
       }
 
       void AssociatedObject_RowEditEnded(object sender, GridViewRowEditEndedEventArgs e)
       {
           // This is the call to Rebind that causes the exception
           AssociatedObject.Rebind();
       }
 
       protected override void OnDetaching()
       {
           AssociatedObject.DataLoaded -= AssociatedObject_DataLoaded;
           AssociatedObject.RowEditEnded -= AssociatedObject_RowEditEnded;
           base.OnDetaching();
       }
 
       void AssociatedObject_DataLoaded(object sender, EventArgs e)
       {
           UpdateTotalLengths();
           UpdateComponentNumber();
       }
 
       private void UpdateComponentNumber()
       {
           Int32 index = 1;
           foreach (MyComponent component in AssociatedObject.Items.OfType<MyComponent>())
           {
               component.Number = index;
               index++;
           }
       }
 
       private void UpdateTotalLengths()
       {
           var totalLength = 0d;
           foreach (var component in AssociatedObject.Items.OfType<MyComponent>())
           {
               totalLength += component.Length;
               component.TotalLength = totalLength;
           }
       }

The basic idea of the above code is that on RowEndEdit and on DataLoaded the cumulativelength value is recalculated.

Everything works as expected when the user selects another row after editing a row (i.e. the cumulative length is updated).  However when the user clicks on anywhere else in the UI an ArgumentNullException is thrown (the message is 'Value cannot be null').  The Stack trace is:

at Telerik.Windows.Controls.ParentOfTypeExtensions.<GetParents>d__0.MoveNext() in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Core\Controls\Extensions\ParentOfTypeExtensions.cs:line 74
at System.Linq.Enumerable.<OfTypeIterator>d__aa`1.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at Telerik.Windows.Controls.GridView.GridViewCell.HandlePendingEdit(UIElement focusedElement) in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Controls\GridView\GridView\GridView\Cells\GridViewCell.cs:line 1021
at Telerik.Windows.Controls.GridView.GridViewCell.HandlePendingEditOnLostFocus() in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Controls\GridView\GridView\GridView\Cells\GridViewCell.cs:line 899
at Telerik.Windows.Controls.GridView.GridViewDataControl.HandleLostFocus(DependencyObject focusedDependencyObject) in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Controls\GridView\GridView\GridView\GridViewDataControl.Editing.cs:line 508
at Telerik.Windows.Controls.GridView.GridViewDataControl.HandleLostFocus() in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Controls\GridView\GridView\GridView\GridViewDataControl.Editing.cs:line 456
at Telerik.Windows.Controls.GridView.GridViewDataControl.OnLostFocus(RoutedEventArgs e) in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Controls\GridView\GridView\GridView\GridViewDataControl.Editing.cs:line 450
at System.Windows.UIElement.IsFocused_Changed(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, Boolean coerceWithCurrentValue, OperationType operationType)
at System.Windows.DependencyObject.ClearValueCommon(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata)
at System.Windows.DependencyObject.ClearValue(DependencyPropertyKey key)
at System.Windows.Input.FocusManager.OnFocusedElementChanged(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, Boolean coerceWithCurrentValue, OperationType operationType)
at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
at System.Windows.Input.FocusManager.SetFocusedElement(DependencyObject element, IInputElement value)
at System.Windows.Input.KeyboardNavigation.UpdateFocusedElement(DependencyObject focusTarget)
at System.Windows.FrameworkElement.OnGotKeyboardFocus(Object sender, KeyboardFocusChangedEventArgs e)
at System.Windows.Input.KeyboardFocusChangedEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
at System.Windows.Input.InputManager.ProcessStagingArea()
at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
at System.Windows.Input.KeyboardDevice.ChangeFocus(DependencyObject focus, Int32 timestamp)
at System.Windows.Input.KeyboardDevice.TryChangeFocus(DependencyObject newFocus, IKeyboardInputProvider keyboardInputProvider, Boolean askOld, Boolean askNew, Boolean forceToNullIfFailed)
at System.Windows.Input.KeyboardDevice.Focus(DependencyObject focus, Boolean askOld, Boolean askNew, Boolean forceToNullIfFailed)
at System.Windows.Input.KeyboardDevice.Focus(IInputElement element)
at System.Windows.UIElement.Focus()
at System.Windows.Controls.ScrollViewer.OnMouseLeftButtonDown(MouseButtonEventArgs e)
at System.Windows.UIElement.OnMouseLeftButtonDownThunk(Object sender, MouseButtonEventArgs e)
at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
at System.Windows.UIElement.OnMouseDownThunk(Object sender, MouseButtonEventArgs e)
at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
at System.Windows.Input.InputManager.ProcessStagingArea()
at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at System.Windows.Interop.HwndSource.InputFilterMessage(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, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)

I have tracked this down to the call to Rebind() on the RowEditEnded.

Note we are trying to use Rebind here instead of just raising PropertyChanged event from component.TotalLength as we are not in control of that library.
Yoan
Telerik team
 answered on 23 Aug 2013
1 answer
93 views
Hi,

I'd like to customize schedule view control so Day view looks like the attached picture. Do you think is possible to reach the desired look?

Thanks.
Rosen Vladimirov
Telerik team
 answered on 23 Aug 2013
2 answers
172 views
I am trying to do MVVM with data binding to GraphSource using a ObservableGraphSourceBase.  When I drop a container from the DiagramToolbox.  How would be able to associate that container with view model item and still be able to undo or redo adding that item to the diagram?
Kent
Top achievements
Rank 1
 answered on 22 Aug 2013
1 answer
286 views
Hello,

I'm wondering how I can let a header do texttrimming?
In the picture below, you can see that my column values are being trimmed, but the header text isn't..

http://imageshack.us/photo/my-images/843/jrsp.png/

Thanks!
Yoan
Telerik team
 answered on 22 Aug 2013
4 answers
288 views
Hi,

how can i add a errorhandling to a RadMaskedTextInput? On LostFocus-Event i check if the Input is ok or not. If the
Input is not ok, i want to clear the RadMaskedTextInput and set the Cursor back in the box.

To clear is no problem:

RadMaskedTextInput.Text = "";

But how to set the Focus?

RadMaskedTextInput.Focus(); does not work.

Thanks Best Regards
Rene
Diego
Top achievements
Rank 1
 answered on 22 Aug 2013
0 answers
61 views

the above code giving the error as "The Resource 'Localized strings ' could't be resolved

<TelerikPopup:GridViewComboBoxColumn.Header>
                                                                <TextBlock Text="{Binding Source={StaticResource localizedStrings}, Path=LabelString.LocalizationResources.UOM, FallbackValue='UOM'}"/>
                                                            </TelerikPopup:GridViewComboBoxColumn.Header>
How to Resolve it


Pranavi
Top achievements
Rank 1
 asked on 22 Aug 2013
1 answer
262 views
How do I prevent the selction changed event from firing when a listbox item is selected for drag drop?

The main WPF form contains the RadDock. The RadDock has a RadPaneGroup that is docked left. RadPanes containing RadListBox controls are added to this RadPaneGroup based on user selection, an example being a list of customers.

The RadDock has a second RadPaneGroup, and this RadPaneGroup is in the DocumentHost property of the RadDock so that its RadPanes open as tabbed documents.

An example of normal behavior is that a RadListbox containing a list of customers appears in a RadPane that is in the docked left RadPaneGroup. A user selects a specific customer from the list, the selection changed event fires, and the application adds a RadPane to the Document host RadPaneGroup so that details about the selected customer are shown as a tabbed document.

One of the user actions is to create a shopping cart. A menu option is chosen and a RadPane containing the shopping cart information is added to the DocumentHost RadPaneGroup. The first thing that a user needs to do is associate a customer to the shopping cart. The idea is that the user would drag a customer from the RadListbox contained in a docked left RadPane onto the RadPane that is in the document host RadPaneGroup and shown as the currently active tabbed document.

My problem is that when I left click and hold down the mouse button to drag an item out of the RadListbox that is in the docked left RadPaneGroup, the RadListbox selection changed event fires, which then opens a customer details RadPane in the tabbed document DocumentHost area; the shopping cart is no longer visible because it is no longer the active tab.

The desired behavior is that the RadListbox selection changed event does not fire during a drag / drop operation so that I can drag the selected customer from the RadListbox contained within the docked left RadPane onto the empty shopping cart RadPane that is displayed as a tabbed document in the DocumentHost.

Do you have any vb.net examples, or documentation that would explain the desired behavior?
Rosen Vladimirov
Telerik team
 answered on 22 Aug 2013
0 answers
177 views
Hello, i'll wrote my app with mvvm pattern and have a problem with selecting item programmatically in resourcedictionary.
I have TreeListView on the one resourcedictionary and GridView in another. Also I have two ObservableCollection 1 and 2 wich i bind.
When user select item in the TreeListView and this item has a reference to another items at this (1) then i add referenced items to anothe ObservableCollection (2). GridView bind to the ObservableCollection (2) and when the user select item from GridView 
at the ObservableCollection (2) I find the same item in ObservableCollection (1) and set the "SelectedItem" to it and the problem is that the  TreeListView didn't Expand parents to the SelectedItem. Help me pleas! Attached example below.
Best Regards,
Dmytro.









Dmytro
Top achievements
Rank 1
 asked on 22 Aug 2013
8 answers
215 views
Hi,

i'm using the "Grouping and Filterung" Example of SchduleVIew. Ther you Add the ResourceTypesSource in xaml.
How do i add the Resources by code behind in this case?

XAML:
<scheduleView:RadScheduleView.ResourceTypesSource>
      <scheduleView:ResourceTypeCollection>
             <scheduleView:ResourceType Name="Category">
                        <scheduleView:Resource ResourceName="Sven Ottlieb" />
                        <scheduleView:Resource ResourceName="Martine Rance" />
                        <scheduleView:Resource ResourceName="Howard Snyder" />
                        <scheduleView:Resource ResourceName="Daniel Tonini" />
                        <scheduleView:Resource ResourceName="John Steel" />
              </scheduleView:ResourceType>
       </scheduleView:ResourceTypeCollection>
</scheduleView:RadScheduleView.ResourceTypesSource>

Code Behind?
Thanks
Best Regrds
Kalin
Telerik team
 answered on 22 Aug 2013
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
Book
FileDialogs
ToolBar
ColorPicker
TimePicker
SyntaxEditor
MultiColumnComboBox
VirtualGrid
Wizard
ExpressionEditor
NavigationView (Hamburger Menu)
DesktopAlert
WatermarkTextBox
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
VirtualKeyboard
HighlightTextBlock
Security
TouchManager
StepProgressBar
Badge
OfficeNavigationBar
ExpressionParser
CircularProgressBar
SvgImage
PipsPager
SlideView
AI Coding Assistant
+? more
Top users last month
Ambisoft
Top achievements
Rank 2
Iron
Pascal
Top achievements
Rank 2
Iron
Matthew
Top achievements
Rank 1
Sergii
Top achievements
Rank 1
Iron
Iron
Andrey
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Ambisoft
Top achievements
Rank 2
Iron
Pascal
Top achievements
Rank 2
Iron
Matthew
Top achievements
Rank 1
Sergii
Top achievements
Rank 1
Iron
Iron
Andrey
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?