Telerik Forums
UI for WPF Forum
1 answer
183 views

When I view the RadGridView, I can hide columns using the IsVissible=false method.  This appears to be ignored when printing.  Is this true and if so, is there another way that I can dynamically cause columns to not be printed?

If all the columns show, it bleeds to a second page and if I force all columns to print on a single page, the font is simply too small to read.

Thanks.

Dilyan Traykov
Telerik team
 answered on 21 Feb 2017
17 answers
788 views

I'm trying to add a tooltiptemplate for the series in my RadCartesianChart. I can't get this to work but I don't see any problem with it.

XAML:

<telerik:ScatterLineSeries x:Key="ToolTipDisplay2">
<telerik:ScatterLineSeries.PointTemplate>
<DataTemplate>
<Ellipse Width="2" Height="2" Fill="Black" />
</DataTemplate>
</telerik:ScatterLineSeries.PointTemplate>
</telerik:ScatterLineSeries>

 

C# code:

... series added...

ScatterLineSeries temp1 = (ScatterLineSeries) this.Resources["ToolTipDisplay2"];
survivalChart.Series[survivalChart.Series.Count() - 1].TooltipTemplate = (DataTemplate) temp1.TooltipTemplate;

 

William
Top achievements
Rank 1
 answered on 21 Feb 2017
2 answers
1.6K+ views

Hi Guys,

I'm struggling with an issue and I can't figure why this goes wrong.

I cannot access my object in the resourcedictionary in my code behind.  What I have is the following
I have a resourcedictionary like this.

 

                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
                    xmlns:telerikScheduleView="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.ScheduleView"
                    xmlns:telerikColorPickers="clr-namespace:Telerik.Windows.Controls.RichTextBoxUI.ColorPickers;assembly=Telerik.Windows.Controls.RichTextBoxUI"
                    xmlns:local="clr-namespace:Proj"
                    xmlns:p="clr-namespace:Proj.Resources"
                    x:Class="Proj.ProductieOrderViewRecources">
 
 
    <DataTemplate x:Key="ProductieOrderViewToolBarTemplate">
        <telerik:RadRichTextBoxRibbonUI x:Name="richTextBoxRibbonUI"

 

this whitin this resourcedictionary
I have a radgridview like this.

<DataTemplate x:Key="ProductieOrderViewMainSectorTemplate">
    <Grid Margin="10">
        <Grid>
            <telerik:RadBusyIndicator x:Name="BusyIndicator" Grid.Row="2" Visibility="{Binding ShowPlanning}" >
                <telerik:RadGridView x:Name="gridViewAdminData"
                                     ItemsSource="{Binding DataRecords}"
                                     RowEditEnded="EditRecord"
                                     DataLoading="LoadData"
                                     SelectionChanged="GridSelectionChanged"
                                     FrozenColumnCount ="5"
                                     AutoGenerateColumns="False"
                                     Deleting="RadGridView_deleting"
                                     SelectedItem="{Binding SelectedPlanning}">
                    <telerik:RadGridView.Columns>
                        <telerik:GridViewDataColumn DataMemberBinding="{Binding Artikel}" IsReadOnly="True" />
                        <telerik:GridViewDataColumn DataMemberBinding="{Binding Aantal}" />

now I'm trying the access the gridViewAdminData by name in the code behind.

but it won't work at all.
I have this in my code

public partial class ProductieOrderViewRecources : ResourceDictionary
{
    public ProductieOrderViewRecources()
    {
        InitializeComponent();
         
            System.Linq.Expressions.Expression<Func<Proj.Models.productieorder, double>> expression = order => (order.AantalTeProduceren + 10);
            //RadGridView gridViewAdminData = (RadGridView)this["gridViewAdminData"];
            GridViewExpressionColumn column = gridViewAdminData.Columns["TotalValue"] as GridViewExpressionColumn;
            column.Expression = expression;
         
    }
}

but gridViewAdminData won't get recognized. Also enabling the line above gives back a null value.

Does anyone have any idea about how to access this object in the code behind?

thank you

Bart
Top achievements
Rank 1
 answered on 21 Feb 2017
6 answers
114 views

Hello,

I have a VisualizationLayer bound to a collection of objects. I've defined a MapEllipseView for (some of) the objects in the collection via an ItemTemplateSelector.
The issue I have is that when I add items to the collection the ellipses are only rendered on the map at the completion of a zoom animation.

How can I get them to appear straight away after they are added in the collection?

Thanks,
Chris

Petar Mladenov
Telerik team
 answered on 21 Feb 2017
4 answers
400 views

I am trying to bind a few ContextMenu items to the selected appointment's properties, however I can't seem to get to the DataContext of the scheduleview.

<telerik:RadMenuItem Header="Requires Nurse..." IsChecked="{Binding Menu.UIElement.SelectedAppointment.Require_Nurse}" />

I've tried RelativeSource up to the ScheduleGrid, or direct to UIElement and everything gives me the same binding expression error that Schedule_VM doesn't contain a property for Require_Nurse.

Is there any way to bind a context menu item to the appointment?  Even if I get it bound will it actually allow modifying of the property?

Brandon
Top achievements
Rank 1
 answered on 20 Feb 2017
10 answers
603 views

Hello,

I'm working on a WPF application using Prism 5 and Telerik UI for WPF R3 2016. The application loads dinamically 2 separate modules (dll) using UnityContainer and inject them in a RadDocking control as follows:

MainWindow.xaml

<Window.Resources>
        <Style TargetType="telerik:RadDocumentPane">
            <Setter Property="Header" Value="{Binding DataContext.Title}"/>
            <Setter Property="HeaderTemplate">
                <Setter.Value>
                    <DataTemplate>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition />
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>
                            <ContentControl VerticalAlignment="Center" HorizontalAlignment="Center"
                                            Margin="0,0,7,0" Content="{Binding}"/>
                            <Button Grid.Column="1" Content="x">
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="Click">
                                        <prism:CloseTabAction/>
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                            </Button>

                        </Grid>
                    </DataTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </Window.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <StackPanel Orientation="Horizontal">
            <Button Content="Toolbar" Command="{Binding ShowToolbarCommand}" Width="50" Height="25" HorizontalAlignment="Left"></Button>
            <Button Content="Home" Command="{Binding ShowHomeCommand}" Width="50" Height="25" HorizontalAlignment="Left"></Button>
        </StackPanel>
        <DockPanel Grid.Row="1" LastChildFill="True">
            <telerikDocking:RadDocking x:Name="Docking" Background="Transparent"
                                      BorderThickness="0">
                <telerikDocking:RadDocking.DocumentHost>
                    <telerikDocking:RadSplitContainer >
                        <telerikDocking:RadPaneGroup regions:RegionManager.RegionName="{x:Static model:RegionNames.ContentRegion}"/>
                    </telerikDocking:RadSplitContainer>
                </telerikDocking:RadDocking.DocumentHost>
                <telerikDocking:RadSplitContainer MaxWidth="400" Width="175" MinWidth="175" InitialPosition="DockedLeft">
                    <telerikDocking:RadPaneGroup>
                        <telerikDocking:RadDocumentPane CanUserClose="False" PaneHeaderVisibility="Collapsed"
                                regions:RegionManager.RegionName="{x:Static model:RegionNames.LeftRegion}">
                        </telerikDocking:RadDocumentPane>
                    </telerikDocking:RadPaneGroup>
                </telerikDocking:RadSplitContainer>
            </telerikDocking:RadDocking>
        </DockPanel>
    </Grid>

CloseTabAction.cs

public class CloseTabAction : TriggerAction<Button>
    {
        protected override void Invoke(object parameter)
        {
            var args = parameter as RoutedEventArgs;
            if (args == null)
                return;
            var tabItem = FindParent<RadPane>(args.OriginalSource as DependencyObject);
            if (tabItem == null)
                return;
            var tabControl = FindParent<RadPaneGroup>(tabItem);
            if (tabControl == null)
                return;

            IRegion region = RegionManager.GetObservableRegion(tabControl).Value;
            if (region == null)
                return;
            RemoveItemFromRegion(tabItem.Content, region);
        }

        void RemoveItemFromRegion(object item, IRegion region)
        {
            var navigationContext = new NavigationContext(region.NavigationService, null);
            if (CanRemove(item, navigationContext))
            {
                InvokeOnNavigatedFrom(item, navigationContext);
                region.Remove(item);
            }
        }

        void InvokeOnNavigatedFrom(object item, NavigationContext navigationContext)
        {
            var navigationAwareItem = item as INavigationAware;
            if (navigationAwareItem != null)
                navigationAwareItem.OnNavigatedFrom(navigationContext);
            var frameworkElement = item as FrameworkElement;
            if (frameworkElement != null)
            {
                INavigationAware navigationAwareDataContext = frameworkElement.DataContext as INavigationAware;
                if (navigationAwareDataContext != null)
                {
                    navigationAwareDataContext.OnNavigatedFrom(navigationContext);
                }
            }
        }

        bool CanRemove(object item, NavigationContext navigationContext)
        {
            bool canRemove = true;
            var confirmRequestItem = item as IConfirmNavigationRequest;
            if (confirmRequestItem != null)
            {
                confirmRequestItem.ConfirmNavigationRequest(navigationContext, result =>
                {
                    canRemove = result;
                });
            }
            var frameworkElement = item as FrameworkElement;
            if (frameworkElement != null && canRemove)
            {
                IConfirmNavigationRequest confirmRequestDataContext = frameworkElement.DataContext as IConfirmNavigationRequest;
                if (confirmRequestDataContext != null)
                {
                    confirmRequestDataContext.ConfirmNavigationRequest(navigationContext, result =>
                    {
                        canRemove = result;
                    });
                }
            }
            return canRemove;
        }

        static T FindParent<T>(DependencyObject child) where T : DependencyObject
        {
            DependencyObject parentObject = VisualTreeHelper.GetParent(child);
            if (parentObject == null)
                return null;
            var parent = parentObject as T;
            if (parent != null)
                return parent;
            return FindParent<T>(parentObject);
        }
    }

I've overrided Prism ScopedRegionNavigationContentLoader in order to allow views injections using navigation to create ScopedRegions:

public class ScopedRegionNavigationContentLoader: IRegionNavigationContentLoader
    {
        private readonly IServiceLocator serviceLocator;

        /// <summary>
        /// Initializes a new instance of the <see cref="RegionNavigationContentLoader"/> class with a service locator.
        /// </summary>
        /// <param name="serviceLocator">The service locator.</param>
        public ScopedRegionNavigationContentLoader(IServiceLocator serviceLocator)
        {
            this.serviceLocator = serviceLocator;
        }

        /// <summary>
        /// Gets the view to which the navigation request represented by <paramref name="navigationContext"/> applies.
        /// </summary>
        /// <param name="region">The region.</param>
        /// <param name="navigationContext">The context representing the navigation request.</param>
        /// <returns>
        /// The view to be the target of the navigation request.
        /// </returns>
        /// <remarks>
        /// If none of the views in the region can be the target of the navigation request, a new view
        /// is created and added to the region.
        /// </remarks>
        /// <exception cref="ArgumentException">when a new view cannot be created for the navigation request.</exception>
        public object LoadContent(IRegion region, NavigationContext navigationContext)
        {
            if (region == null) throw new ArgumentNullException("region");
            if (navigationContext == null) throw new ArgumentNullException("navigationContext");

            string candidateTargetContract = this.GetContractFromNavigationContext(navigationContext);

            var candidates = this.GetCandidatesFromRegion(region, candidateTargetContract);

            var acceptingCandidates =
                candidates.Where(
                    v =>
                    {
                        var navigationAware = v as INavigationAware;
                        if (navigationAware != null && !navigationAware.IsNavigationTarget(navigationContext))
                        {
                            return false;
                        }

                        var frameworkElement = v as FrameworkElement;
                        if (frameworkElement == null)
                        {
                            return true;
                        }

                        navigationAware = frameworkElement.DataContext as INavigationAware;
                        return navigationAware == null || navigationAware.IsNavigationTarget(navigationContext);
                    });


            var view = acceptingCandidates.FirstOrDefault();

            if (view != null)
            {
                return view;
            }

            view = this.CreateNewRegionItem(candidateTargetContract);

            region.Add(view, null, CreateRegionManagerScope(view));

            return view;
        }

        private bool CreateRegionManagerScope(object view)
        {
            bool createRegionManagerScope = false;

            var viewHasScopedRegions = view as ICreateRegionManagerScope;
            if (viewHasScopedRegions != null)
                createRegionManagerScope = viewHasScopedRegions.CreateRegionManagerScope;

            return createRegionManagerScope;
        }

        /// <summary>
        /// Provides a new item for the region based on the supplied candidate target contract name.
        /// </summary>
        /// <param name="candidateTargetContract">The target contract to build.</param>
        /// <returns>An instance of an item to put into the <see cref="IRegion"/>.</returns>
        protected virtual object CreateNewRegionItem(string candidateTargetContract)
        {
            object newRegionItem;
            try
            {           
                newRegionItem = this.serviceLocator.GetInstance<object>(candidateTargetContract);
            }
            catch (ActivationException e)
            {
                throw new InvalidOperationException(
                    string.Format(CultureInfo.CurrentCulture, "Cannot create navigation target", candidateTargetContract),
                    e);
            }
            return newRegionItem;
        }

        /// <summary>
        /// Returns the candidate TargetContract based on the <see cref="NavigationContext"/>.
        /// </summary>
        /// <param name="navigationContext">The navigation contract.</param>
        /// <returns>The candidate contract to seek within the <see cref="IRegion"/> and to use, if not found, when resolving from the container.</returns>
        protected virtual string GetContractFromNavigationContext(NavigationContext navigationContext)
        {
            if (navigationContext == null) throw new ArgumentNullException("navigationContext");

            var candidateTargetContract = UriParsingHelper.GetAbsolutePath(navigationContext.Uri);
            candidateTargetContract = candidateTargetContract.TrimStart('/');
            return candidateTargetContract;
        }

        /// <summary>
        /// Returns the set of candidates that may satisfiy this navigation request.
        /// </summary>
        /// <param name="region">The region containing items that may satisfy the navigation request.</param>
        /// <param name="candidateNavigationContract">The candidate navigation target as determined by <see cref="GetContractFromNavigationContext"/></param>
        /// <returns>An enumerable of candidate objects from the <see cref="IRegion"/></returns>
        protected virtual IEnumerable<object> GetCandidatesFromRegion(IRegion region, string candidateNavigationContract)
        {
            if (region == null) throw new ArgumentNullException("region");
            return region.Views.Where(v =>
                string.Equals(v.GetType().Name, candidateNavigationContract, StringComparison.Ordinal) ||
                string.Equals(v.GetType().FullName, candidateNavigationContract, StringComparison.Ordinal));
        }
    }

 

Everything works fine for creation / add RadPanes except Closing and Moving event.

On Close, the the exception is: An unhandled exception of type 'System.InvalidCastException' occurred in Telerik.Windows.Controls.Docking.dll

Additional information: Unable to cast object of type 'ModuleA.Views.ModuleAHomeView' to type 'Telerik.Windows.Controls.RadPane'.

but hostControl is a valid RadPaneGroup and Items collection DO contain ModuleA.Views.ModuleAHomeView

On Move,  I've got a NullReferenceExceltopn at Telerik.Windows.Controls.RadPane.OnHeaderMouseLeftButtonDown(Object sender, MouseButtonEventArgs e)

 

Any help would be highly appreciated.

Best regards,

Alin Halatiu

Alin
Top achievements
Rank 1
 answered on 20 Feb 2017
1 answer
132 views
how to increase the height of row in radscheduler
Stefan Nenchev
Telerik team
 answered on 20 Feb 2017
2 answers
335 views
Hello.
I'm looking into migrating from Google maps.
How to work with two layers (or overlays) with different projections?
For example, I need EPSG:3857 (like OpenStreetMap) and EPSG:3395 (like Yandex Maps) on one map.

In Google maps api I had to create Custom Projection and implement fromLatLngToPixel and fromPixelToLatLng, then create custom Tile Layer and implement loadTile.

Could you provide an example?
Thank you.
Massimo
Top achievements
Rank 1
 answered on 17 Feb 2017
1 answer
100 views

Hi Telerik,

We've implemented the drag/drop feature for the RadGridView available in the code samples (using the RowReorderBehavior, etc).

Is there a way to highlight the rows that were dropped (i.e. GVR background=Orange)? We've made several attempts to no avail - is there a way to do this without binding to a property in the ViewModel?

 

Kind regards

Yoan
Telerik team
 answered on 17 Feb 2017
8 answers
494 views
I'm attempting to add a basic legend to go along with my dynamically generated line series:
<telerik:RadCartesianChart.SeriesProvider>
   <telerik:ChartSeriesProvider Source="{Binding VisiblePortfolios}">
      <telerik:ChartSeriesProvider.SeriesDescriptors>
         <telerik:CategoricalSeriesDescriptor ItemsSourcePath="EquityCurve" ValuePath="Value" CategoryPath="Date">
            <telerik:CategoricalSeriesDescriptor.Style>
               <Style TargetType="telerik:LineSeries">
                  <Setter Property="StrokeThickness" Value="2"/>
                  <Setter Property="LegendSettings">
                     <Setter.Value>
                        <telerik:SeriesLegendSettings Title="{Binding Name}"/>
                     </Setter.Value>
                  </Setter>
               </Style>
            </telerik:CategoricalSeriesDescriptor.Style>
         </telerik:CategoricalSeriesDescriptor>
      </telerik:ChartSeriesProvider.SeriesDescriptors>
   </telerik:ChartSeriesProvider>
</telerik:RadCartesianChart.SeriesProvider>

However, this error occurs when I debug:

System.Windows.Data Error: 2 : Cannot find governing FrameworkElement or FrameworkContentElement for target element. BindingExpression:Path=DataContext.Name; DataItem=null; target element is 'SeriesLegendSettings' (HashCode=10926182); target property is 'Title' (type 'String')

And the legend does not appear at all. Any assistance is greatly appreciated.
Martin Ivanov
Telerik team
 answered on 17 Feb 2017
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
+? more
Top users last month
Miljana
Top achievements
Rank 2
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Bronze
Cynthia
Top achievements
Rank 1
John
Top achievements
Rank 1
Iron
Mozart
Top achievements
Rank 1
Iron
Veteran
Want to show your ninja superpower to fellow developers?
Top users last month
Miljana
Top achievements
Rank 2
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Bronze
Cynthia
Top achievements
Rank 1
John
Top achievements
Rank 1
Iron
Mozart
Top achievements
Rank 1
Iron
Veteran
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?