Telerik Forums
UI for WPF Forum
9 answers
769 views

Hi Team,

We were previously using the 2017.2.614.45 version of the Telerik controls and were facing memory leak issues with RadGridView. We have hence upgraded to 2018.3.1016.45 version of the controls but still are facing the same memory leak issues. 

We use RadPane which is placed in a RadPaneGroup; the pane in turn contains the RadGridView. We have handled the closed event of the RadPaneGroup wherein we do our cleanup operations(unsubscribing RadGridView events, setting DataContext as null). As stated in one of the forum posts, we also do the cleanup operations advised which is given at the end. 

Please also find the memory profile report of our application when we closed the RadPane. 

Kindly advise.

 

Regards,

Swapnil Ramteke

private void radDocking_Close(object sender, Telerik.Windows.Controls.Docking.StateChangeEventArgs e)
        {
            try
            {
                if (e.Panes.Count() == 1)
                {
                    var pane = e.Panes.ElementAt(0);
                    if (pane is IDispose)
                    {
                        (pane as IDispose).Dispose();
                    }
 
                    pane.Content = null;
                    pane.Header = null;
                    pane.DataContext = null;
                    pane.RemoveFromParent();
                    pane = null;
                    // Wait for 5 seconds before garbage collection
                    System.Threading.Tasks.Task.Delay(5000).ContinueWith(antecedent =>
                        {
                            GC.WaitForPendingFinalizers();
                            GC.Collect();
                        });
                }
            }
            catch (Exception)
            {
 
            }
        }
Pawel
Top achievements
Rank 1
 answered on 26 Dec 2018
8 answers
240 views

Hi every body ....

I use RadRichTextBox in the following manner: first page is used (by the user) as a cover letter so that it is not included within the total count of pages. Footer of every page except first page should display page number x from y, where x is the current page number (after the first page), and y is the total number of pages minus one (the first page).

I could achieve the first value of the formatted footer using CodeBasedField, but unfortunately I couldn't modify the value returned by NumPagesField.

My question is how to modify value returned by NumPagesField so that I can display total number of pages minus one. Below there is an attachment of an image to show my requirement.

The following is my code snippet used in creating the custom footer:

Public Function FirstTemplate() As RadDocument
Dim section As New Section()
 section.HasDifferentFirstPageHeaderFooter = True
section.Footers.[Default] = New Footer With {.Body = ReportFooter()}
End Function
 
Private Function ReportFooter() As RadDocument
    Dim footerDoc As New RadDocument
Dim footerSection As New Section
            Dim footerParagraph As New Paragraph
            Dim footerDocumentEditor As New RadDocumentEditor(footerDoc)
 
            footerParagraph.TextAlignment = RadTextAlignment.Center
            footerDoc.Sections.Add(footerSection)
            footerSection.Blocks.Add(footerParagraph)
            footerDocumentEditor.InsertField(New FormattedPageNumber, FieldDisplayMode.Result)
            footerDocumentEditor.InsertField(New NumPagesField, FieldDisplayMode.Result) '??? how to return total number of pages -1
 
            Return footerDoc
        End Function
 
Public Class FormattedPageNumber
        Inherits CodeBasedField
        Public Shared ReadOnly FieldType As String = "FormattedPageNUM"
 
        Shared Sub New()
            CodeBasedFieldFactory.RegisterFieldType(FormattedPageNumber.FieldType, Function()
                                                                                       Return New FormattedPageNumber()
                                                                                   End Function)
        End Sub
 
        Public Overrides ReadOnly Property FieldTypeName() As String
            Get
                Return FormattedPageNumber.FieldType
            End Get
        End Property
 
        Protected Overrides Function GetResultFragment() As DocumentFragment
            Dim pageNumber As Integer = 0
            'Dim pagesCount As Integer = 0
            If Me.Document IsNot Nothing Then
                Dim position As New DocumentPosition(Me.Document)
                position.MoveToStartOfDocumentElement(Me.FieldStart)
                Dim sectionBox As SectionLayoutBox = position.GetCurrentSectionBox()
 
                pageNumber = sectionBox.PageNumber
            End If
 
            Dim resultString As String = "Page " & pageNumber - 1 & " From "
 
            Return MyBase.CreateFragmentFromText(resultString)
        End Function
 
        Public Overrides Function CreateInstance() As Field
            Return New FormattedPageNumber()
        End Function
    End Class
Peshito
Telerik team
 answered on 26 Dec 2018
7 answers
96 views

I was trying to use RadMultiColumnComboBox in RadGridView with programatic filtering. The filtered item of the ComboBox(in Col3) is depend on the value of Col1 and Col2. The problem is to get the "Y" object. I donot know how.

<telerik:RadGridView ItemsSource="{Binding X}>
      <telerik:RadGridView.Columns>
        <telerik:GridViewDataColumn Header="Col1" DataMemberBinding="{Binding XA}"/>
        <telerik:GridViewDataColumn Header="Col2" DataMemberBinding="{Binding XB}"/>
        <telerik:GridViewDataColumn Header="Col3">
          <telerik:GridViewDataColumn.CellTemplate>
            <DataTemplate>
              <telerik:RadMultiColumnComboBox>
                <telerik:RadMultiColumnComboBox.ItemsSourceProvider>
                  <telerik:GridViewItemsSourceProvider ItemsSource="{Binding Y}" AutoGenerateColumns="False"> (*** used FindAncestor aproach***)
                    <telerik:GridViewItemsSourceProvider.Columns>
                      <telerik:GridViewDataColumn Header="SubCol1" DataMemberBinding="{Binding YA}"/>
                      <telerik:GridViewDataColumn Header="SubCol2" DataMemberBinding="{Binding YB}"/>
                    </telerik:GridViewItemsSourceProvider.Columns>
                  </telerik:GridViewItemsSourceProvider>
                </telerik:RadMultiColumnComboBox.ItemsSourceProvider>
              </telerik:RadMultiColumnComboBox>
            </DataTemplate>
          </telerik:GridViewDataColumn.CellTemplate>
        </telerik:GridViewDataColumn>
      </telerik:RadGridView.Columns>
    </telerik:RadGridView>

I tryed following but every time I find null.

-- .ChildrenOfType<>()

-- .Columns["<col_name>"]

-- FindResource() (***as DataTemplete declared as Resource***)

 

     

Stefan
Telerik team
 answered on 24 Dec 2018
5 answers
953 views

Hi,

 

I tried a hierarchical grid like this:

 

<telerik:GridView Grid.Row="2" RowIndicatorVisibility="Collapsed" CanUserSelect="False" IsReadOnly="True" ItemsSource="{Binding ProductConfigurations}" ShowInsertRow="False" CanUserInsertRows="False" CanUserReorderColumns="False" ShowGroupPanel="False" CanUserEditRows="False" CanUserDeleteRows="False" AutoGenerateColumns="False">
    <telerik:GridView.HierarchyChildTemplate>
        <DataTemplate>
            <telerik:GridView Grid.Row="1" Margin="24,0,0,0" RowIndicatorVisibility="Collapsed" CanUserSelect="False" IsReadOnly="True" ItemsSource="{Binding ProductConfigurationVariants}" ShowInsertRow="False" CanUserInsertRows="False" CanUserReorderColumns="False" ShowGroupPanel="False" CanUserEditRows="False" CanUserDeleteRows="False" AutoGenerateColumns="False">
                <telerik:GridView.Columns>
                    <telerik:GridViewDataColumn Header="VariantNr" DataMemberBinding="{Binding VariantNr}" Width="90" IsSortable="True" IsFilterable="False" />
                    <telerik:GridViewDataColumn Header="SalesOrderCode" DataMemberBinding="{Binding SalesOrderCode}" Width="120" IsFilterable="True" />
                    <telerik:GridViewDataColumn Header="ProductionOrderCode" DataMemberBinding="{Binding ProductionOrderCode}" Width="*" IsSortable="True" IsFilterable="False"/>
                    <telerik:GridViewDataColumn Header="NavTransferID" DataMemberBinding="{Binding NavTransferID}" Width="100" IsFilterable="False" IsSortable="False" />
                    <telerik:GridViewDataColumn Header="NavTransferStatus" DataMemberBinding="{Binding NavTransferStatus}" Width="120" IsFilterable="False" IsSortable="False" />
                    <telerik:GridViewDataColumn Header="NavTransferActionCode" DataMemberBinding="{Binding NavTransferActionCode}" Width="140" IsFilterable="False" IsSortable="False" />
                </telerik:GridView.Columns>
            </telerik:GridView>
        </DataTemplate>
    </telerik:GridView.HierarchyChildTemplate>
    <telerik:GridView.ChildTableDefinitions>
        <telerik:GridViewTableDefinition>
            <telerik:GridViewTableDefinition.Relation>
                <telerik:PropertyRelation ParentPropertyName="ProductConfiguration"/>
            </telerik:GridViewTableDefinition.Relation>                            
        </telerik:GridViewTableDefinition>
    </telerik:GridView.ChildTableDefinitions>
    <telerik:GridView.Columns>
        <telerik:GridViewDataColumn Header="ItemNr" DataMemberBinding="{Binding ItemNr}" Width="80" IsSortable="True" IsFilterable="False" />
        <telerik:GridViewDataColumn Header="ItemStatus" DataMemberBinding="{Binding ItemStatus}" Width="90" IsSortable="True" IsFilterable="False" />
        <telerik:GridViewDataColumn Header="PLMItemNumber" DataMemberBinding="{Binding PLMItemNumber}" Width="120" IsFilterable="True" />
        <telerik:GridViewDataColumn Header="HWProductionOrderCode" DataMemberBinding="{Binding HWProductionOrderCode}" Width="*" IsSortable="True" IsFilterable="False"/>
        <telerik:GridViewDataColumn Header="NavTransferID" DataMemberBinding="{Binding NavTransferID}" Width="100" IsFilterable="False" IsSortable="False" />
        <telerik:GridViewDataColumn Header="NavTransferStatus" DataMemberBinding="{Binding NavTransferStatus}" Width="120" IsFilterable="False" IsSortable="False" />
        <telerik:GridViewDataColumn Header="NavTransferActionCode" DataMemberBinding="{Binding NavTransferActionCode}" Width="140" IsFilterable="False" IsSortable="False" />
        <telerik:GridViewDataColumn Header="NumVar" DataMemberBinding="{Binding ProductConfigurationVariants.Count}" Width="60" IsSortable="False" IsFilterable="False"/>
    </telerik:GridView.Columns>
</telerik:GridView>

This works so far - but the child grid is extremely wide.
I can remove this behavior when I have no column with Width="*" in the child.
With the Width="*" this columns fills more than the width of the parent grid.

All other columns are fix - but this one can contain longer text - so removing the "*" is not an option.
The desired outcome is a child Grid that fills the parent - with one column "AutoExpanding".

 

As a workaroundI tried to bind the Width of the child grid to another element on the UserControl - Width="{Binding ActualWidth, ElementName=xRect}".

But this results in a binding error.

Manfred

Stefan
Telerik team
 answered on 24 Dec 2018
1 answer
164 views

Hi,I'm sorting a TreeListView clicking the header. See the structure below. All the top rows are sorted fine (Ascending and Descending), A5 row have 1 child level and is sorted good too. But A1 that have more than 1 level of children doesn't work. If I keep A1 with 1 level of children (just F1 and A2) the sort works. So TreeListView support sort with more that 1 horizontal level of children ?

A1 - 0
          F1- 1
          A2 - 2

                    F2 - 3 

                     A3 - 4

                               A4 - 5
                               F3- 6
A5 - 7
           F4-8
           F5-9
F6-10
F7-11

This is my xaml:

 

<telerik:RadTreeListView Grid.Row="2" x:Name="DeckDataGrid"
                               EnableLostFocusSelectedState="False"
                               CanUserSortColumns="True"
                               SelectionMode="Single"
                               cal:Message.Attach="[Event Sorting] = [Action SortingHandler($source, $eventArgs)]"
                               ItemsSource="{Binding Source={StaticResource EngineeringDeckMarksView}}"
                               TreeLinesVisibility="Hidden"
                               SelectedItem="{Binding SelectedDeckMark, Mode=TwoWay}"
                               HierarchyColumnIndex="1">
        <telerik:RadTreeListView.SortDescriptors >
          <telerik:SortDescriptor Member="MarkNumber" />
        </telerik:RadTreeListView.SortDescriptors>
        <telerik:RadTreeListView.ChildTableDefinitions>
          <telerik:TreeListViewTableDefinition ItemsSource="{Binding ChildrenDeckMarks}" />
        </telerik:RadTreeListView.ChildTableDefinitions>
        <telerik:RadTreeListView.Columns>
          <telerik:GridViewDataColumn MinWidth="32" IsSortable="True" SortMemberPath="IsSelected" EditTriggers="None">
            <telerik:GridViewDataColumn.CellTemplate>
              <DataTemplate DataType="deck:IBaseDeckMarkViewModel">
                <CheckBox Margin="10 0 0 0"
                          CommandParameter="{Binding}"
                          IsChecked="{Binding IsSelected, Mode=TwoWay}" />
              </DataTemplate>
            </telerik:GridViewDataColumn.CellTemplate>
          </telerik:GridViewDataColumn>
          <telerik:GridViewDataColumn HeaderCellStyle="{StaticResource StyleMarkHeader}" CellStyle="{StaticResource StyleMark}" Header="Mark" SortingState="Ascending" DataMemberBinding="{Binding DeckIndex}"  MinWidth="100" Width="120" IsReadOnly="True" />
          <telerik:GridViewDataColumn Header="Bundle" SortingState="Descending" DataMemberBinding="{Binding Bundle, TargetNullValue='--', FallbackValue='--', StringFormat='{}{0}'}" MinWidth="100" Width="100" IsReadOnly="True" />
          <telerik:GridViewDataColumn Header="Qty" SortingState="Ascending" DataMemberBinding="{Binding Quantity, TargetNullValue='--', FallbackValue='--' }" MinWidth="71" Width="71" IsReadOnly="True" />
          <telerik:GridViewDataColumn Header="Avail&#x0a;Qty" SortingState="Ascending" DataMemberBinding="{Binding AvailableQuantity, TargetNullValue='--', FallbackValue='--', StringFormat='{}{0}' }" MinWidth="80" Width="100" IsReadOnly="True" />
          <telerik:GridViewDataColumn Header="Length" SortingState="Ascending" DataMemberBinding="{Binding Length, TargetNullValue='--', FallbackValue='--', StringFormat='{}{0}', Converter={StaticResource LengthDisplayConverter}, ConverterParameter=FractionalFeet8th}" MinWidth="90" Width="90" IsReadOnly="True" />
          <telerik:GridViewDataColumn Header="Designation" SortingState="Descending" DataMemberBinding="{Binding Designation, TargetNullValue='--', FallbackValue='--', StringFormat='{}{0}' }" MinWidth="140" Width="150" IsReadOnly="True" />
          <telerik:GridViewDataColumn Header="Gage" SortingState="Descending" DataMemberBinding="{Binding Gage, TargetNullValue='--', FallbackValue='--', StringFormat='{}{0}' }" MinWidth="70" Width="70" IsReadOnly="True" />
          <telerik:GridViewDataColumn Header="Galv" SortingState="Ascending" SortMemberPath="GalvanizationThickness" DataMemberBinding="{Binding Galvanization, TargetNullValue='--', FallbackValue='--', StringFormat='{}{0}'}" MinWidth="70" Width="70" IsReadOnly="True" />
          <telerik:GridViewDataColumn Header="Top&#x0a;Finish" SortingState="Ascending" DataMemberBinding="{Binding TopFinish, TargetNullValue='--', FallbackValue='--', StringFormat='{}{0}' }" MinWidth="90" Width="90" IsReadOnly="True" />
          <telerik:GridViewDataColumn Header="Bot&#x0a;Finish" SortingState="Ascending" DataMemberBinding="{Binding BottomFinish, TargetNullValue='--', FallbackValue='--', StringFormat='{}{0}' }" MinWidth="90" Width="90" IsReadOnly="True" />
          <telerik:GridViewDataColumn Header="Emboss" SortingState="Ascending" DataMemberBinding="{Binding Emboss, TargetNullValue='--', FallbackValue='--', StringFormat='{}{0}'}" MinWidth="110" Width="110" IsReadOnly="True" />
          <telerik:GridViewDataColumn Header="Acoustic" SortingState="Ascending" DataMemberBinding="{Binding Acoustic, TargetNullValue='--', FallbackValue='--', StringFormat='{}{0}' }" MinWidth="110" Width="110" IsReadOnly="True" />
          <telerik:GridViewDataColumn Header="Perf" SortingState="Ascending" DataMemberBinding="{Binding Perforation, TargetNullValue='--', FallbackValue='--', StringFormat='{}{0}' }" MinWidth="80" Width="120" IsReadOnly="True" />
          <telerik:GridViewDataColumn Header="Yield" SortingState="Ascending" DataMemberBinding="{Binding Yield, TargetNullValue='--', FallbackValue='--', StringFormat='{}{0}' }" MinWidth="80" Width="120" IsReadOnly="True" />
          <telerik:GridViewDataColumn Header="Wt Ea" SortingState="Ascending" DataMemberBinding="{Binding WeightEach, TargetNullValue='--', FallbackValue='--', StringFormat='{}{0}', Converter={StaticResource RoundAwayFromZeroConverter}, ConverterParameter=2}" MinWidth="80" Width="120" IsReadOnly="True" />
          <telerik:GridViewDataColumn Header="Bundle&#x0a;Desc" SortingState="Ascending" DataMemberBinding="{Binding BundleDescription, TargetNullValue='--', FallbackValue='--', StringFormat='{}{0}' }" Width="110" MinWidth="110" IsReadOnly="True" />
          <telerik:GridViewDataColumn Header="Width" SortingState="Ascending" DataMemberBinding="{Binding Width, TargetNullValue='--', FallbackValue='--', StringFormat='{}{0}' }" MinWidth="105" Width="*" IsReadOnly="True" />
        </telerik:RadTreeListView.Columns>
      </telerik:RadTreeListView>

 

Stefan
Telerik team
 answered on 24 Dec 2018
2 answers
253 views

Hi!

I need to change the default timezone of my schedule view. Is there any way to do this? In this case, for example, I want to show every date and time in my scheduleview to be displayed in UTC or any other timezone that I can specify.

Stefan
Telerik team
 answered on 24 Dec 2018
1 answer
95 views

I want to use TreeListView for creating a financial statement. The columns are reporting periods determined at run time. The number of reporting periods is determined at run time.

It looks something like this.

Element                                     Jan                   Feb               Mar             April

AccountsReceivable                  10                     20                  40              90

Inventory                                    33                     66                  34            454

 

Column 1 is a heiractical list of elements

the other columns are a collection for each element that consists of:

Period (2018-Jan)

Value $100

How would I bind the reporting period column with the element row. I have the data. It is a matter of presenting it.

Yoan
Telerik team
 answered on 24 Dec 2018
1 answer
603 views

Hi, I'm relatively new in WPF and using the Telerik Controls. I'll go to my problem, I'm getting this error

System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='Trial.ViewModel.DeviceViewModel', AncestorLevel='1''. BindingExpression:Path=SelectedField; DataItem=null; target element is 'RadGridView' (Name='BitField'); target property is 'SelectedItem' (type 'Object')

I appreciate your help in giving the solution to my problem.

So... this is my current setup:

ListView.xaml

<UserControl x:Class="Trial.Views.RegisterListView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:local="clr-namespace:Trial.Views"
             xmlns:viewmodel="clr-namespace:Trial.ViewModel"
             xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
             xmlns:diag="clr-namespace:System.Diagnostics;assembly=WindowsBase"
             mc:Ignorable="d"
             d:DesignHeight="300" d:DesignWidth="600">
    <Grid>
        <Grid.Resources>
            <DataTemplate x:Key="RowDetailsTemplate">
                <telerik:RadGridView Name="BitField" ItemsSource="{Binding Fields}" SelectedItem="{Binding Path=SelectedField, RelativeSource={RelativeSource AncestorType={x:Type viewmodel:DeviceViewModel}}}" AutoGenerateColumns="False" RowIndicatorVisibility="Collapsed">
                    <telerik:RadGridView.Columns>
                        <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}"/>
                        <telerik:GridViewDataColumn DataMemberBinding="{Binding Value}"/>
                        <telerik:GridViewDataColumn Header="Command">
                            <telerik:GridViewDataColumn.CellEditTemplate>
                                <DataTemplate>
                                    <StackPanel Orientation="Horizontal">
                                        <telerik:RadButton CornerRadius='15' Width="80" Height='30' Margin="10 10 0 0" ToolTip='Read Register' Content='Read' KeyboardNavigation.TabIndex="2" Command="{Binding Path=ReadRegisterCommand, RelativeSource={RelativeSource AncestorType={x:Type viewmodel:DeviceViewModel}}}"/>
                                    </StackPanel>
                                </DataTemplate>
                            </telerik:GridViewDataColumn.CellEditTemplate>
                        </telerik:GridViewDataColumn>
                        <telerik:GridViewDataColumn DataMemberBinding="{Binding Documentation}"/>
                    </telerik:RadGridView.Columns>
                </telerik:RadGridView>
            </DataTemplate>
        </Grid.Resources>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="300"/>
        </Grid.ColumnDefinitions>
        <telerik:RadGridView ItemsSource="{Binding Registers}" SelectedItem="{Binding SelectedRegister}" RowDetailsTemplate="{StaticResource RowDetailsTemplate}" AutoExpandGroups="False" RowIndicatorVisibility="Collapsed">
            <telerik:RadGridView.Columns>
                <telerik:GridViewToggleRowDetailsColumn/>
                <telerik:GridViewDataColumn Header="Register Name" DataMemberBinding="{Binding Name}"/>
                <telerik:GridViewDataColumn Header="Register Address" DataMemberBinding="{Binding Address}"/>
                <telerik:GridViewDataColumn Header="Register Value" DataMemberBinding="{Binding Value}"/>
                <telerik:GridViewDataColumn Header="Description" DataMemberBinding="{Binding Desc}"/>
            </telerik:RadGridView.Columns>
        </telerik:RadGridView>
    </Grid>
</UserControl>

=====================================================

DeviceViewModel.cs

public ObservableCollection<RegisterDetails> Registers
        {
            get
            {
                if (Registers != null)
                {
                    return this.Registers;
                }
                else
                {
                    return null;
                }
            }
        }

public RegisterDetails SelectedRegister
        {
            get
            {
                return this.selectedRegister;
            }

            set
            {
                this.selectedRegister = value;
                this.RaisePropertyChanged("SelectedRegister");
            }
        }

public FieldDetails SelectedField
        {
            get
            {
                return this.selectedField;
            }

            set
            {
                this.selectedField = value;
                this.RaisePropertyChanged("SelectedField");
            }
        }

=====================================================

RegisterDetails.cs

public class RegisterDetails
{
    public string Name { get; set; }
    public uint Address { get; set; }
    public uint Value { get; set; }
    public string Desc { get; set; }
    public FieldDetails[] Fields { get; set; }
}

=====================================================

FieldDetails.cs

public class FieldDetails
{
    public string Name { get; set; }
    public uint Value { get; set; }
    public string Documentation { get; set; }
}

Yoan
Telerik team
 answered on 24 Dec 2018
3 answers
181 views
I'm using UriImage provider as a base class to allow me to display various image files (e.g. floor plans). I don't have geographic coordinates for the images but I want to overlay data on the image relative to the image bottom left, using pixel coordinates. I've configured my provider class to use EPSG900913Projection as its spatial reference. Effectively my image should be displayed with the bottom left corner at 0,0. This is what my provider class looks like:
public class SchematicProvider : UriImageProvider, ICloneable
{
    private SchematicViewModel _viewModel;
    // EPSG900913Projection is a proportional projection so should work for arbitrary units (i.e. IPSC schematic maps)
    private readonly EPSG900913Projection _projection = new EPSG900913Projection();
 
    public override ISpatialReference SpatialReference => _projection;
 
    public SchematicProvider(SchematicViewModel viewModel)
    {
        _viewModel = viewModel;
        var mediaFileName = viewModel.GetMediaFileName();
 
        var topLeft = new Location(6000, 0);
        var bottomRight = new Location(0, 8000);
        // If I don't include this line, I can't zoom in and out of the image
        // but including this line makes the app crash when I click on the minimap button
        GeoBounds = new LocationRect(topLeft, bottomRight);
 
        Uri = new Uri(mediaFileName);
    }
 
    public new object Clone()
    {
        var provider = new SchematicProvider(_viewModel);
        InheritCurrentSource(provider);
        InheritParameters(provider);
        return provider;
    }
 
    protected override void Dispose(bool disposing)
    {
        _viewModel = null;
        base.Dispose(disposing);
    }
}

My view model looks like this:

public class SchematicViewModel
{
    private readonly string _imageName;
 
    public SchematicViewModel(string imageName)
    {
        _imageName = imageName;
    }
 
    public string GetMediaFileName()
    {
        return _imageName;
    }
}

And the code behind looks like this:

public MainWindow()
{
    InitializeComponent();
    RadMap1.SpatialReference = new EPSG900913Projection();
    RadMap1.Provider = new SchematicProvider(new SchematicViewModel("C:\\temp\\image.png"));
    // image is 8000 wide by 6000 high and I want to position the map center on the image center
    RadMap1.Center = new Location(3000, 4000);
}

 

If I don't set the GoeBounds in the provider then I can't zoom and pan as expected. If I do set the GeoBounds then when I click the minimap button the app crashes with the following exception:

System.ArgumentException
  HResult=0x80070057
  Message=Width and Height must be non-negative.
  Source=WindowsBase
  StackTrace:
   at System.Windows.Size..ctor(Double width, Double height)
   at Telerik.Windows.Controls.Map.SpatialReference.GetSizeInKilometers(Location basePoint, Size size)
   at Telerik.Windows.Controls.Map.LocationRect.CalculateGeographicalSize()
   at Telerik.Windows.Controls.Map.TilesVisualizationLayer.CalculateRegion()
   at Telerik.Windows.Controls.Map.TilesVisualizationLayer.OnMapChanged(RadMap oldMap, RadMap newMap)
   at Telerik.Windows.Controls.Map.InformationLayer.InformationLayerLoaded(Object sender, RoutedEventArgs e)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.BroadcastEventHelper.BroadcastEvent(DependencyObject root, RoutedEvent routedEvent)
   at System.Windows.BroadcastEventHelper.BroadcastLoadedEvent(Object root)
   at MS.Internal.LoadedOrUnloadedOperation.DoWork()
   at System.Windows.Media.MediaContext.FireLoadedPendingCallbacks()
   at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
   at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
   at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext 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, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   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.Application.RunDispatcher(Object ignore)
   at System.Windows.Application.RunInternal(Window window)
   at ProvidersUriImageProvider.App.Main()

 

What am I doing wrong?

Thanks

Pete

 

 

 

Peter
Top achievements
Rank 1
Veteran
 answered on 22 Dec 2018
2 answers
468 views

I have been trying without success to edit a copy of the Material theme for RadGridView in order to make the scrollbars wider.  I have been able to make the outer part wider, but not the inner bar. (that you drag)  Would you happen to have an example?  I would also accept changing the scrollbars globally. (I have tried that too but with no success)

I did try to follow the steps in https://docs.telerik.com/devtools/wpf/styling-and-appearance/how-to/styling-apperance-styling-scrollbars

but have had no luck with that either.  Advanced WPF styling is still bewildering to me or I might have been able to figure this out on my own.

Joshua
Top achievements
Rank 2
 answered on 21 Dec 2018
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?