Telerik Forums
UI for WPF Forum
2 answers
116 views

     I am attempting to style a CartesianChartGrid's X and Y lines by setting the StrokeDashArray property.  However, when attempting to run the application, I receive an exception stating that the doublecollection must be unfrozen.  Here is the code snippet and I have attached the resulting exception message..

 

      <telerik:RadCartesianChart Width="400" Height="250">
            <telerik:RadCartesianChart.HorizontalAxis>
                <telerik:LinearAxis />
            </telerik:RadCartesianChart.HorizontalAxis>
            <telerik:RadCartesianChart.VerticalAxis>
                <telerik:LinearAxis/>
            </telerik:RadCartesianChart.VerticalAxis>
            <telerik:ScatterPointSeries>
                <telerik:ScatterPointSeries.DataPoints>
                    <telerik:ScatterDataPoint XValue="1" YValue="1" />
                    <telerik:ScatterDataPoint XValue="5" YValue="3" />
                    <telerik:ScatterDataPoint XValue="8" YValue="11" />
                </telerik:ScatterPointSeries.DataPoints>
            </telerik:ScatterPointSeries>
            <telerik:RadCartesianChart.Grid>
                <telerik:CartesianChartGrid MajorLinesVisibility="XY" >
                    <telerik:CartesianChartGrid.MajorXLineStyle>
                        <Style TargetType="Line">
                            <Setter Property="Stroke" Value="Pink"/>
                            <Setter Property="StrokeDashArray" Value="4,2"/>
                        </Style>
                    </telerik:CartesianChartGrid.MajorXLineStyle>
                </telerik:CartesianChartGrid>
            </telerik:RadCartesianChart.Grid>
        </telerik:RadCartesianChart>

Jeremy
Top achievements
Rank 1
 answered on 13 Sep 2019
1 answer
899 views

Hi,

This view basically displays Questions, Question Choices and selects or displays the answer as well. The Question Choices can be a Yes/No, MultipleSelect, MultipleChoice or FreeText.  The view has a RadGridView on line 260 and this grid has RowDetailsTemplate which displays question number and question text in a RadGridView . This RadGridView has has RowDetailsTemplateSelector which displays the Question Choices which is either Yes/NO or Multiple Choice or Free Text etc based on the  Question Type. This in turn calls the DataTemplates. Basically with this complex nested GridViews and Templates and the ModelView methods, the view takes at least 3 minutes to load 30 questions. 

How can I improve the performance of this View?

Your guidance is appreciated.

 

View:

<UserControl.Resources>
           <DataTemplate x:Key="SurveyQuestionMultipleChoiceDataTemplate">
            <StackPanel Grid.Column="1" Orientation="Vertical" Width="Auto" HorizontalAlignment="Left" Margin="35,0,0,0"  >
                <RadioButton  HorizontalAlignment="Left"   VerticalAlignment="Center" Content="{Binding SurveyChoiceText}" IsChecked="{Binding IsChecked}"  FontSize="13"
                                        GroupName="SurveyQuestionRadioGroup" />
            </StackPanel>
        </DataTemplate>
 
        <DataTemplate x:Key="SurveyQuestionMultipleSelectDataTemplate">
            <StackPanel Grid.Column="1" Orientation="Vertical" Width="Auto" HorizontalAlignment="Left"  Margin="30,5,0,0" >
                <CheckBox  HorizontalAlignment="Left" HorizontalContentAlignment="Center" Content="{Binding SurveyChoiceText}"  IsChecked="{Binding IsChecked}" FontSize="13"
                                                              telerik:StyleManager.Theme="Office_Black" />
            </StackPanel>
        </DataTemplate>
 
        <DataTemplate x:Key="SurveyQuestionsRankingDataTemplate">
            <StackPanel Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Left"  Margin="23,0,0,0" Width="Auto">
                <ComboBox Name="cbxRank"  DisplayMemberPath="RankNumberID"
                          VerticalAlignment="Center"
                          HorizontalAlignment="Left"
                          Margin="10,10,0,0"
                          ItemsSource="{Binding Rank}"  >
                </ComboBox>
                <TextBlock Text="{Binding SurveyChoiceText}"  TextWrapping="Wrap" Width="Auto" VerticalAlignment="Center" Margin="5,0,0,0" FontSize="13" />
            </StackPanel>
        </DataTemplate>
    </ResourceDictionary>
</UserControl.Resources>
<Grid>
    <Border Margin="20">
        <Grid Width="Auto">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <Grid.Resources>
                <telerik:NullToVisibilityConverter x:Key="NullToVisibilityConverter" />
                 
                <DataTemplate x:Key="YesNoTemplate" >
                    <StackPanel Orientation="Vertical" >
                        <StackPanel Orientation="Horizontal"  Margin="30,10,10,15" Width="Auto">
                            <RadioButton IsChecked="{Binding  SrvyAnswer.IsYesChecked}" Content="Yes" VerticalAlignment="Center" GroupName="YesNo" />
                            <RadioButton IsChecked="{Binding  SrvyAnswer.IsNoChecked}"  Content="No" VerticalAlignment="Center" GroupName="YesNo" />
                        </StackPanel>
                        <StackPanel Orientation="Horizontal"  Margin="30,0,0,5">
                            <TextBlock Text="{Binding SrvyAnswer.Comments}" IsEnabled="False" Height="Auto" Width="1400"  TextWrapping="Wrap" FontSize="13" Margin="5,10,10,15" />
                        </StackPanel>
                    </StackPanel>
 
                </DataTemplate>
                 
                <DataTemplate x:Key="MultipleChoiceTemplate">
 
                    <telerik:RadListBox ItemsSource="{Binding SurveyQuestionAnswers}" VerticalAlignment="Top" 
                            ItemTemplate="{StaticResource SurveyQuestionMultipleChoiceDataTemplate}" />
 
                </DataTemplate>
                 
                <DataTemplate x:Key="MultipleSelectTemplate">
                    <StackPanel Orientation="Vertical">
                        <telerik:RadListBox ItemsSource="{Binding SurveyQuestionAnswers}" VerticalAlignment="Top"  BorderThickness="0"  Margin="0,0,10,10"
                                ItemTemplate="{StaticResource SurveyQuestionMultipleSelectDataTemplate}" />
 
                        <StackPanel Orientation="Horizontal" Visibility="{Binding SurveyAnswersCommentForMultipleSelect,  Converter={StaticResource NullToVisibilityConverter}  }">
                            <TextBlock Name="txtTotalResponses" Text="{Binding SurveyAnswersCommentForMultipleSelect}"  Width="1200" TextWrapping="Wrap"
                                                            Grid.Column="1"  FontWeight="Regular"  FontSize="13"
                                                            HorizontalAlignment="Left" VerticalAlignment="Center"  Margin="40,0,0,10"  />
                            </StackPanel>
                    </StackPanel>
                </DataTemplate>
                 
                <DataTemplate x:Key="FreeTextTemplate">
                    <Border BorderThickness="0" BorderBrush="Black" Margin="35,0,0,0" Padding="4">
                        <StackPanel Orientation="Horizontal" >
                            <TextBlock Text="{Binding SrvyAnswer.SelectedAnswer}" IsEnabled="False" Height="Auto" Width="1400"  TextWrapping="Wrap" FontSize="13"  />
                        </StackPanel>
                    </Border>
                </DataTemplate>
                 
                <DataTemplate x:Key="RankingTemplate">
                    <telerik:RadListBox ItemsSource="{Binding SurveyQuestionAnswers}" VerticalAlignment="Top"
                            ItemTemplate="{StaticResource SurveyQuestionsRankingDataTemplate}" />
                </DataTemplate>
 
                <SurveyConverter:SurveyQuestionTypeConverter x:Key="sqtconverter" />
 
                <SurveyTemplateRules:ConditionalDataTemplateSelector x:Key="selector"
                                                  ConditionConverter="{StaticResource sqtconverter}">
                    <SurveyTemplateRules:ConditionalDataTemplateSelector.Rules>
                        <SurveyTemplateRules:ConditionalDataTemplateRule DataTemplate="{StaticResource YesNoTemplate}">
                            <SurveyTemplateRules:ConditionalDataTemplateRule.Value>
                                <sys:Int32>1</sys:Int32>
                            </SurveyTemplateRules:ConditionalDataTemplateRule.Value>
                        </SurveyTemplateRules:ConditionalDataTemplateRule>
                        <SurveyTemplateRules:ConditionalDataTemplateRule DataTemplate="{StaticResource MultipleChoiceTemplate}">
                            <SurveyTemplateRules:ConditionalDataTemplateRule.Value>
                                <sys:Int32>2</sys:Int32>
                            </SurveyTemplateRules:ConditionalDataTemplateRule.Value>
                        </SurveyTemplateRules:ConditionalDataTemplateRule>
                        <SurveyTemplateRules:ConditionalDataTemplateRule DataTemplate="{StaticResource MultipleSelectTemplate}">
                            <SurveyTemplateRules:ConditionalDataTemplateRule.Value>
                                <sys:Int32>3</sys:Int32>
                            </SurveyTemplateRules:ConditionalDataTemplateRule.Value>
                        </SurveyTemplateRules:ConditionalDataTemplateRule>
                        <SurveyTemplateRules:ConditionalDataTemplateRule DataTemplate="{StaticResource FreeTextTemplate}">
                            <SurveyTemplateRules:ConditionalDataTemplateRule.Value>
                                <sys:Int32>4</sys:Int32>
                            </SurveyTemplateRules:ConditionalDataTemplateRule.Value>
                        </SurveyTemplateRules:ConditionalDataTemplateRule>
                        <SurveyTemplateRules:ConditionalDataTemplateRule DataTemplate="{StaticResource RankingTemplate}">
                            <SurveyTemplateRules:ConditionalDataTemplateRule.Value>
                                <sys:Int32>5</sys:Int32>
                            </SurveyTemplateRules:ConditionalDataTemplateRule.Value>
                        </SurveyTemplateRules:ConditionalDataTemplateRule>
                    </SurveyTemplateRules:ConditionalDataTemplateSelector.Rules>
                </SurveyTemplateRules:ConditionalDataTemplateSelector>
                 
                <DataTemplate x:Key="RowDetailsTemplateForQuestions">
                    <telerik:RadGridView Name="surveyQuestionsGrid"
                                 ItemsSource="{Binding SurveyQuestions}"
                                        AutoGenerateColumns="False"
                                        IsReadOnly="True"
                                        ShowColumnSortIndexes="False"
                                        CanUserDeleteRows="False"
                                        CanUserInsertRows="False"
                                        CanUserSortColumns="False"
                                        CanUserFreezeColumns="False"
                                        CanUserGroupColumns="False"
                                        CanUserSelect="False"
                                        CanUserSortGroups="False"
                                        ShowGroupPanel="False"
                                        ShowColumnHeaders="False"
                                        GroupRenderMode="Flat"
                                        CanUserSelectColumns="False"
                                        GridLinesVisibility="None"
                                        RowIndicatorVisibility ="Collapsed"
                                        BorderBrush="White"                                           
                                        ScrollViewer.HorizontalScrollBarVisibility="Visible"
                                        ScrollViewer.VerticalScrollBarVisibility="Visible" 
                                        ScrollViewer.CanContentScroll="True"
                                        RowDetailsTemplateSelector="{StaticResource selector}"
                                        RowDetailsVisibilityMode="Visible">
                        <telerik:RadGridView.Columns>
                            <telerik:GridViewDataColumn  Width="Auto">
                                <telerik:GridViewDataColumn.CellTemplate>
                                    <DataTemplate>
                                        <TextBlock Text="{Binding SortOrder}" HorizontalAlignment="Right" VerticalAlignment="Top"  Height="Auto" FontWeight="Bold" TextWrapping="Wrap"  />
                                        <!--<Label Content="." HorizontalAlignment="Left" VerticalAlignment="Top"  Height="Auto" FontWeight="Bold"/>-->
                                    </DataTemplate>
                                </telerik:GridViewDataColumn.CellTemplate>
                            </telerik:GridViewDataColumn>
                            <telerik:GridViewDataColumn  Width="Auto">
                                <telerik:GridViewDataColumn.CellTemplate>
                                    <DataTemplate >
                                        <TextBlock Text="{Binding QuestionText}"  HorizontalAlignment="Left" VerticalAlignment="Top"  Height="Auto" FontWeight="Bold"  Width="1700" TextWrapping="Wrap"  />
                                        <!--<TextBlock TextAlignment="Left" TextWrapping="Wrap" Width="1700"  Text="{Binding QuestionText}" FontWeight="Bold"  Margin="0,10,0,10" ></TextBlock>-->
                                    </DataTemplate>
                                </telerik:GridViewDataColumn.CellTemplate>
                            </telerik:GridViewDataColumn>
                        </telerik:RadGridView.Columns>
                    </telerik:RadGridView>
                </DataTemplate>
 
            </Grid.Resources>
 
 
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,10,0,0" Grid.Row="1">
                <TextBlock Text="View Details Sort by Jurisdiction - " Grid.Row="0"  FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="14" FontFamily="Segoe UI Semibold" />
                <TextBlock Text="{Binding SurveyTitle}" Grid.Row="0"  FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="14" FontFamily="Segoe UI Semibold" />
            </StackPanel>
             
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="0,10,0,0" Grid.Row="2" Width="Auto">
                <telerik:RadButton Content="Back To Survey Search" Width="150" Height="25"  Grid.Row="0"  HorizontalAlignment="Left"
                                        Margin="5 0 0 5" CornerRadius="10"
                                         Cursor="Hand"
                                        Command="{Binding BackToSurveySearch}">
 
                    <ToolTipService.ToolTip>
                        <ToolTip Content="Back to Survey Search" />
                    </ToolTipService.ToolTip>
                </telerik:RadButton>
                <telerik:RadButton Content="Aggregate Results" Width="170" Height="25"  Grid.Row="0"  HorizontalAlignment="Left"
                                        Margin="10 0 0 5" CornerRadius="10"
                                         Cursor="Hand"
                                        Command="{Binding AggregateResults}">
 
                    <ToolTipService.ToolTip>
                        <ToolTip Content="Aggregate Results" />
                    </ToolTipService.ToolTip>
                </telerik:RadButton>
                <telerik:RadButton Content="Details Sorted by Question" Width="170" Height="25"  Grid.Row="0"  HorizontalAlignment="Left"
                                        Margin="10 0 0 5" CornerRadius="10"
                                         Cursor="Hand"
                                        Command="{Binding DetailsSortedByQuestion}">
 
                    <ToolTipService.ToolTip>
                        <ToolTip Content="View all details Sorted by Question" />
                    </ToolTipService.ToolTip>
                </telerik:RadButton>
 
            </StackPanel>
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,10,0,0" Grid.Row="3">
                <TextBlock Text="Sort by Jurisdiction - " Grid.Row="0"  FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="12" FontFamily="Segoe UI Semibold" />
                <telerik:RadComboBox x:Name="radComboBoxJurisdictionOptions"
                                                 Width="220"  VerticalAlignment="Center" SelectedIndex="0"
                                                 SelectedValuePath="StateCode"
                                                 DisplayMemberPath="StateName"
                                                 Height="25"
                                                 ItemsSource="{Binding Jurisdictions}"
                                                 SelectedValue="{Binding SelectedJurisdictionCode}"
                                                 SelectedItem="{Binding SelectedSurveyJurisdiction}"
                                                 Command="{Binding ChangeJurisdictionCommand}"
                                                 CommandParameter="{Binding Path=SelectedItem, ElementName=radComboBoxJurisdictionOptions }"
                                                 AllowMultipleSelection="False"/>                   
            </StackPanel>
 
 
            <StackPanel Orientation="Horizontal" Margin="0,10,0,10" Width="Auto"  Grid.Row="4">
                    <telerik:RadGridView  x:Name="rgvResponses" Width="Auto"
 
                                        ItemsSource="{Binding SurveyResponses}"
                                        AutoGenerateColumns="False"
                                        IsReadOnly="True"
                                        ShowColumnSortIndexes="False"
                                        CanUserDeleteRows="False"
                                        CanUserInsertRows="False"
                                        CanUserSortColumns="False"
                                        CanUserFreezeColumns="False"
                                        CanUserGroupColumns="False"
                                        CanUserSelect="False"
                                        CanUserSortGroups="False"
                                        ShowGroupPanel="False"
                                        ShowColumnHeaders="False"
                                        GroupRenderMode="Flat"
                                        CanUserSelectColumns="False"
                                        GridLinesVisibility="None"
                                        RowIndicatorVisibility ="Collapsed"
                                        BorderBrush="White"
                                        AlternationCount="1"
                                        AlternateRowBackground="LightGray"
                                        ScrollViewer.VerticalScrollBarVisibility="Visible"
                                        RowDetailsTemplate="{StaticResource RowDetailsTemplateForQuestions}"
                                        RowDetailsVisibilityMode="Visible">
                        <telerik:RadGridView.Columns>
                            <telerik:GridViewDataColumn  Width="Auto">
                                <telerik:GridViewDataColumn.CellTemplate>
                                    <DataTemplate>
                                        <StackPanel Orientation="Vertical" Margin="10,10,10,10">
                                            <StackPanel Orientation="Horizontal">
                                                <telerik:Label Content="Name:"  FontWeight="Bold" Grid.Row="1" Grid.Column="0" Margin="0,0,5,0" HorizontalContentAlignment="Right" HorizontalAlignment="Right" VerticalAlignment="Center" Width="150" />
                                                <telerik:Label Name="txtAuthor" Content="{Binding FullName, Mode=OneWay}" Grid.Column="1" Grid.Row="0" FontWeight="Regular" HorizontalAlignment="Left" VerticalAlignment="Center"  Width="Auto"  />
                                            </StackPanel>
                                            <StackPanel Orientation="Horizontal">
                                                 <telerik:Label Content="Attachment:"  FontWeight="Bold" Grid.Row="2" Grid.Column="0" Margin="0,0,5,0" HorizontalContentAlignment="Right" HorizontalAlignment="Right" VerticalAlignment="Center" Width="150" />
                                                 <TextBlock Grid.Column="1" Grid.Row="2" HorizontalAlignment="Left" VerticalAlignment="Center"  Width="Auto">
                                                    <Hyperlink Command="{Binding OpenAttachmentCommand}" CommandParameter="{Binding SurveyID}" >
                                                        <TextBlock Text="{Binding FileName, Mode=OneWay}" FontWeight="Regular" ></TextBlock>
                                                    </Hyperlink>
                                                </TextBlock>
                                            </StackPanel>
                                            <StackPanel Orientation="Horizontal">
                                                <telerik:Label Content="Contact Info/Comments:"  FontWeight="Bold"  Grid.Row="3" Grid.Column="0" Margin="0,0,5,0" HorizontalAlignment="Right" VerticalAlignment="Top"  Width="150"/>
                                                <TextBlock  Grid.Row="2" Grid.Column="1" Text="{Binding Comments, Mode=OneWay}"  Margin="0,0,5,0"  TextWrapping="Wrap"  Height="Auto" Width="Auto" FontWeight="Regular"
                                                              HorizontalAlignment="Left" VerticalAlignment="Center"/>
                                            </StackPanel>
                                            <StackPanel Orientation="Horizontal">
                                            <telerik:Label Content="Jurisdiction:"  FontWeight="Bold" Grid.Row="4" Grid.Column="0" Margin="0,0,5,0"  HorizontalContentAlignment="Right" HorizontalAlignment="Right" VerticalAlignment="Center"  Width="150" />
                                                <telerik:Label  Name="txtJurisdiction" Content="{Binding Jurisdiction, Mode=OneWay}"  Grid.Row="3" Grid.Column="1" FontWeight="Regular" HorizontalAlignment="Left" VerticalAlignment="Center" Width="Auto"/>
                                            </StackPanel>
                                        </StackPanel>
                                    </DataTemplate>
                                </telerik:GridViewDataColumn.CellTemplate>
                            </telerik:GridViewDataColumn>
                        </telerik:RadGridView.Columns>
                 </telerik:RadGridView>
 
            </StackPanel>
            <StackPanel Grid.Row="5" Width="Auto" >
            <telerik:RadDataPager x:Name="radDataPager"
                            PageSize="1"
                            IsTotalItemCountFixed="True"
                            DisplayMode="All"
                           ScrollViewer.VerticalScrollBarVisibility="Visible"
                            FontSize="12"
                            AutoEllipsisMode="Both"
                            NumericButtonCount="10"
                            Margin="0,10,0,0"
                            Style="{StaticResource RadDataPagerStyle1}"
                            Source="{Binding Items, ElementName=rgvResponses}" />
            </StackPanel>
        </Grid>
    </Border>
</Grid>

 

ViewModel:

namespace .Survey.ViewModels
{
 
     
    public class SortByJurisdictionViewModel : BindableBase, INavigationAware
    {
        private IEventAggregator _eventAggregator;
        private ILogger _logger;
        private IRegionManager _regionManager;
        private SurveyDB _surveyDB;
        private SurveyService _surveyService;
        public DelegateCommand<object> BackToSurveySearch { get; private set; }
        public DelegateCommand<object> DetailsSortedByQuestion { get; private set; }
        public DelegateCommand<object> AggregateResults { get; private set; }
        public DelegateCommand<object> OpenAttachmentCommand { get; private set; }
 
 
        #region Page Properties
 
        private int _surveyID;
        public int SurveyID
        {
            set
            {
                _surveyID = value;
                RaisePropertyChanged("SurveyID");
            }
            get
            {
                return _surveyID;
            }
        }
 
        private string _surveyTitle;
        public string SurveyTitle
        {
            set
            {
                _surveyTitle = value;
                RaisePropertyChanged("SurveyTitle");
            }
            get
            {
                return _surveyTitle;
            }
        }
 
        public SurveyResponse _surveyResponseItems;
        public SurveyResponse SurveyResponseItems
        {
            get
            {
                return _surveyResponseItems;
            }
            set
            {
                _surveyResponseItems = value;
                RaisePropertyChanged("SurveyResponseItems");
            }
        }
 
 
        public ObservableCollection<SurveyResponse> _surveyResponses { set; get; }
        public ObservableCollection<SurveyResponse> SurveyResponses
        {
            set
            {
                _surveyResponses = value;
                RaisePropertyChanged("SurveyResponses");
            }
            get
            {
                return _surveyResponses;
            }
        }
        public ObservableCollection<SurveyQuestion> _surveyQuestions { set; get; }
        public ObservableCollection<SurveyQuestion> SurveyQuestions
        {
            set
            {
                _surveyQuestions = value;
                RaisePropertyChanged("SurveyQuestions");
            }
            get
            {
                return _surveyQuestions;
            }
        }
 
        List<SurveyJurisdiction> _jurisdictions;
        public List<SurveyJurisdiction> Jurisdictions
        {
            get
            {
                return this._jurisdictions;
            }
            set
            {
                _jurisdictions = value;
                RaisePropertyChanged("Jurisdictions");
            }
        }
        private SurveyJurisdiction _selectedSurveyJurisdiction;
        public SurveyJurisdiction SelectedSurveyJurisdiction
        {
            set
            {
                _selectedSurveyJurisdiction = value;
                RaisePropertyChanged("SelectedSurveyJurisdiction");
            }
            get
            {
                return _selectedSurveyJurisdiction;
            }
        }
 
        private ICommand changeJurisdictionCommand = null;
 
        public ICommand ChangeJurisdictionCommand
        {
            get
            {
                return this.changeJurisdictionCommand;
            }
            set
            {
                if (this.changeJurisdictionCommand != value)
                {
                    this.changeJurisdictionCommand = value;
                    RaisePropertyChanged("ChangeJurisdictionCommand");
                }
            }
        }
 
 
        #endregion
 
        public SortByJurisdictionViewModel(ILogger logger, SurveyDB survey, IEventAggregator ea, SurveyService surveyService, NetForumCore netForumCoreDB, IRegionManager rm)
        {
            _logger = logger;
            _eventAggregator = ea;
            _surveyDB = survey;
            _regionManager = rm;
            _netForumCoreDB = netForumCoreDB;
            _surveyService = surveyService;
 
            _eventAggregator.GetEvent<AppEnvironmentChange>().Subscribe(OnEnvironmentChange);
            BackToSurveySearch = new DelegateCommand<object>(LaunchSurveySearch);
            DetailsSortedByQuestion = new DelegateCommand<object>(LaunchDetailsSortedByQuestion);
            AggregateResults = new DelegateCommand<object>(LaunchAggregateResults);
            OpenAttachmentCommand = new DelegateCommand<object>(OnClickOpenAttachmentCommand);
 
            this.ChangeJurisdictionCommand = new Telerik.Windows.Controls.DelegateCommand(this.OnJurisdictionChanged);
        }
 
        private void OnClickOpenAttachmentCommand(object param)
        {
 
            string url = "https://xxx.xxx.org/Survey/User/FileDetail.aspx?SurveyFile=" + param;
            Utility.OpenExternalLink(url);
 
        }
 
        private void OnJurisdictionChanged(object param)
        {
            var sj = param as SurveyJurisdiction;
            LoadRecordsForJurisdiction(sj);
        }
 
        private void LoadRecordsForJurisdiction(SurveyJurisdiction sj)
        {
            if(sj != null) GetSurveyResponses(_logger, SurveyID,sj.StateCode, -1);
        }
        private void LaunchDetailsSortedByQuestion(object obj)
        {
            var uri = new Uri("SortByQuestion", UriKind.RelativeOrAbsolute);
            NavigationParameters p = new NavigationParameters();
            p.Add("SurveyID", SurveyID);
            p.Add("SurveyTitle", SurveyTitle);
            _regionManager.RequestNavigate(SurveyModule.ContentRegionName, uri, p);
        }
 
        private void LaunchAggregateResults(object obj)
        {
            var uri = new Uri("AggregateResults", UriKind.RelativeOrAbsolute);
            NavigationParameters p = new NavigationParameters();
            p.Add("SurveyID", SurveyID);
            p.Add("SurveyTitle", SurveyTitle);
            _regionManager.RequestNavigate(SurveyModule.ContentRegionName, uri, p);
        }
 
        private void LaunchSurveySearch(object obj)
        {
            var uri = new Uri("SurveySearch", UriKind.RelativeOrAbsolute);
            _regionManager.RequestNavigate("ContentRegion", uri);
        }
 
        private void OnEnvironmentChange(Environments obj)
        {
            // GetRecords();
            RaisePropertyChanged(); // broadcast full refresh
        }
 
        #region navigation methods
        public void OnNavigatedTo(NavigationContext navigationContext)
        {
            var surveyID = navigationContext.Parameters["SurveyID"];
            var title = navigationContext.Parameters["SurveyTitle"];
 
            _surveyID = UConvert.ConvertToInt32(surveyID);
            _surveyTitle  = UConvert.ConvertToString(title);
            RaisePropertyChanged("SurveyTitle");
            GetSurveyResponses(_logger, SurveyID, string.Empty, -1);
            FillJurisdictionsDropDown();
        }
 
 
        public bool IsNavigationTarget(NavigationContext navigationContext)
        {
            return true;
        }
 
        public void OnNavigatedFrom(NavigationContext navigationContext)
        {
        }
 
        #endregion
 
        private void FillJurisdictionsDropDown()
        {
 
                this._jurisdictions = _surveyService.GetAllJurisdictions(_logger, _netForumCoreDB);
                // Remove states not in responses
                List<SurveyJurisdiction> removeRows = new List<SurveyJurisdiction>();
                foreach (SurveyJurisdiction s in _jurisdictions)
                {
                    string jur = UConvert.ConvertToString(s.StateCode);
                    if (GetSurveyResponsesCount(SurveyID, jur) == 0)
                    {
                        removeRows.Add(s);
                    }
                }
 
                foreach (SurveyJurisdiction surj in removeRows)
                {
                    _jurisdictions.Remove(surj);
                }
 
                SurveyJurisdiction sj = new SurveyJurisdiction();
                sj.StateCode = sj.StateName = sj.StateKey = "";
                _jurisdictions.Insert(0, sj);
 
                Jurisdictions = _jurisdictions;
                RaisePropertyChanged("Jurisdictions");
 
        }
 
 
        public int GetSurveyResponsesCount(int surveyID, string Juris)
        {
            DataTable dt = _surveyDB.GetSurveyResponses(SurveyID, Juris);
            if (dt != null)
            {
                return dt.Rows.Count;
            }
            return -1;
        }
 
        public void GetSurveyResponses(ILogger ilogger, int surveyID, string Juris, int SurveyResponseID)
        {
            ObservableCollection<SurveyResponse> surveyResponseItems = new ObservableCollection<SurveyResponse>();
            DataTable dt = _surveyDB.GetSurveyResponses(SurveyID, Juris);
            try
            {
                if (dt != null)
                {
                    if ((dt.Rows.Count > 0))
                    {
                        foreach (DataRow row in dt.Rows)
                        {
                            SurveyResponse sItem = new SurveyResponse(ilogger, _surveyDB);
 
                            sItem.SurveyID = UConvert.ConvertToInt32(row["SurveyID"]);
                            sItem.SurveyResponseID = UConvert.ConvertToInt32(row["SurveyResponseID"]);
                            sItem.Deleted = UConvert.ConvertToInt32(row["Deleted"]);
 
                            sItem.ResponseDate = UConvert.ConvertToDateTime(row["ResponseDate"]);
                            sItem.FullName = UConvert.ConvertToString(row["FullName"]);
 
                            if(string.IsNullOrEmpty(sItem.FullName) )
                                sItem.FullName = "Anonymous";
 
                            sItem.UserName = UConvert.ConvertToString(row["UserName"]);
                            sItem.Jurisdiction = UConvert.ConvertToString(row["Jurisdiction"]);
                            sItem.Comments = UConvert.ConvertToString(row["Comments"]).Trim();
 
                            if (row["FileImage"] != DBNull.Value)
                            {
 
                                if (row["FileName"] != null && (Convert.ToString(row["FileName"]).Trim() != string.Empty))
                                    sItem.FileName = Convert.ToString(row["FileName"]);
                                sItem.FileType = Convert.ToString(row["FileType"]);
 
                                sItem.FileSize = UConvert.ConvertToInt32(row["FileSize"]);
                                sItem.FileImage = Convert.ToString(row["FileImage"]);
                            }
 
                            sItem.SurveyQuestions = GetSurveyQuestions(ilogger, sItem.SurveyID, sItem.SurveyResponseID);
                           // sItem.SurveyQuestionAnswers = GetQuestionAnswers(sItem.SurveyQuestionID);
 
 
                            surveyResponseItems.Add(sItem);
                        }
                        SurveyResponses = surveyResponseItems;
 
                    }
                }
            }
            catch (Exception ex)
            {
                _logger?.LogError($"Failed during GetSurveyResponses method {ex.Message}");
                throw;
            }
        }
 
        public ObservableCollection<SurveyQuestion> GetSurveyQuestions(ILogger ilogger, int surveyID, int surveyResponseID)
        {
            ObservableCollection<SurveyQuestion> surveyQuestions = new ObservableCollection<SurveyQuestion>();
 
            DataTable dsQuestions = _surveyDB.GetQuestions(surveyID);
 
            if (dsQuestions != null)
            {
                if (dsQuestions != null && dsQuestions.Rows.Count > 0)
                {
                    foreach (DataRow row in dsQuestions.Rows)
                    {
                        SurveyQuestion sq = new SurveyQuestion(ilogger, _surveyDB);
                        sq.SortOrder = UConvert.ConvertToInt32(row["SortOrder"]);
                        sq.SurveyQuestionID = UConvert.ConvertToInt32(row["SurveyQuestionID"]);
                        sq.SurveyQuestionTypeID = UConvert.ConvertToInt32(row["SurveyQuestionTypeID"]);
                        sq.SurveyID = UConvert.ConvertToInt32(row["SurveyID"]);
                        sq.AllowComment = UConvert.ConvertToBoolean(row["AllowComment"]);
                        sq.QuestionText = UConvert.ConvertToString(row["QuestionText"]);
 
                        if (sq.SurveyQuestionTypeID == 3)
                        {
                            sq.SurveyAnswers = GetSurveyAnswersForMultipleSelect(surveyResponseID, sq.SurveyQuestionID);
                            foreach (var answer in sq.SurveyAnswers)
                            {
                                //iterate only one record as all field values for comments are same
                                sq.SurveyAnswersCommentForMultipleSelect = answer.Comments;
                                break;
                            }
                                 
                            sq.SurveyQuestionAnswers = GetQuestionAnswers(sq.SurveyQuestionID, sq.SurveyAnswers); //choices
                        }
                        else
                        {
                            sq.SrvyAnswer = GetSurveyAnswer(surveyResponseID, sq.SurveyQuestionID);
                            sq.SurveyQuestionAnswers = GetQuestionAnswers(sq.SurveyQuestionID, sq.SrvyAnswer); //choices
                        }
 
 
                        surveyQuestions.Add(sq);
                    }
                }
            }
 
            return surveyQuestions;
        }
 
        public ObservableCollection<SurveyQuestionAnswer> GetQuestionAnswers(int surveyQuestionID , SurveyAnswer surveyAnswer) //, int surveyQuestionTypeID)
        {
            DataTable dtSurveyQuestionChoices = null;
            ObservableCollection<SurveyQuestionAnswer> surveyQuestionnAnswers = new ObservableCollection<SurveyQuestionAnswer>();
            try
            {
                dtSurveyQuestionChoices = _surveyDB.GetQuestionAnswers(_logger, surveyQuestionID);
                if (dtSurveyQuestionChoices != null && dtSurveyQuestionChoices.Rows.Count > 0)
                {
                    foreach (DataRow row in dtSurveyQuestionChoices.Rows)
                    {
                        SurveyQuestionAnswer surveyQuestionAnswer = new SurveyQuestionAnswer(_logger, _surveyDB);
                        surveyQuestionAnswer.SurveyChoiceText = UConvert.ConvertToString(row["SurveyChoiceText"]);
                        surveyQuestionAnswer.SurveyChoiceID = UConvert.ConvertToInt32(row["SurveyChoiceID"]);
                        surveyQuestionAnswer.SortOrder = UConvert.ConvertToInt32(row["SortOrder"]);
                        surveyQuestionAnswer.SurveyQuestionID = UConvert.ConvertToInt32(row["SurveyQuestionID"]);
                        surveyQuestionAnswer.IsChecked =  (surveyAnswer.SelectedAnswerValue.Equals(surveyQuestionAnswer.SurveyChoiceID))?  true : false;
 
                        surveyQuestionnAnswers.Add(surveyQuestionAnswer);
                    }
                }
            }
            catch
            {
                throw;
            }
            return surveyQuestionnAnswers;
        }
 
        public ObservableCollection<SurveyQuestionAnswer> GetQuestionAnswers(int surveyQuestionID, ObservableCollection<SurveyAnswer> surveyAnswers) //, int surveyQuestionTypeID)
        {
            DataTable dtSurveyQuestionChoices = null;
            ObservableCollection<SurveyQuestionAnswer> surveyQuestionnAnswers = new ObservableCollection<SurveyQuestionAnswer>();
            try
            {
                dtSurveyQuestionChoices = _surveyDB.GetQuestionAnswers(_logger, surveyQuestionID);
                if (dtSurveyQuestionChoices != null && dtSurveyQuestionChoices.Rows.Count > 0)
                {
                    foreach (DataRow row in dtSurveyQuestionChoices.Rows)
                    {
                        SurveyQuestionAnswer surveyQuestionAnswer = new SurveyQuestionAnswer(_logger, _surveyDB);
                        surveyQuestionAnswer.SurveyChoiceText = UConvert.ConvertToString(row["SurveyChoiceText"]);
                        surveyQuestionAnswer.SurveyChoiceID = UConvert.ConvertToInt32(row["SurveyChoiceID"]);
                        surveyQuestionAnswer.SortOrder = UConvert.ConvertToInt32(row["SortOrder"]);
                        surveyQuestionAnswer.SurveyQuestionID = UConvert.ConvertToInt32(row["SurveyQuestionID"]);
                        foreach (var answer in surveyAnswers)
                        {
                            if (answer.SelectedAnswerValue.Equals(surveyQuestionAnswer.SurveyChoiceID))
                            {
                                surveyQuestionAnswer.IsChecked = true;
                                break;
                            }
                            else
                            {
                                surveyQuestionAnswer.IsChecked = false;
                            }
                        }
 
                        surveyQuestionnAnswers.Add(surveyQuestionAnswer);
                    }
                }
            }
            catch
            {
                throw;
            }
            return surveyQuestionnAnswers;
        }
 
        public ObservableCollection<SurveyAnswer>  GetSurveyAnswersForMultipleSelect(int surveyResponseID, int surveyQuestionID) //, int surveyQuestionTypeID)
        {
            DataTable dtSurveyAnswers = null;
            ObservableCollection<SurveyAnswer>   surveyAnswers = new ObservableCollection<SurveyAnswer>();
            try
            {
                dtSurveyAnswers = _surveyDB.GetSurveyAnswer(_logger, surveyResponseID, surveyQuestionID);
                if (dtSurveyAnswers != null && dtSurveyAnswers.Rows.Count > 0)
                {
                    foreach (DataRow row in dtSurveyAnswers.Rows)
                    {
                        SurveyAnswer surveyAnswer = new SurveyAnswer(_logger, _surveyDB);
 
                        surveyAnswer.SurveyAnswerID = UConvert.ConvertToInt32(row["SurveyAnswerID"]);
                        surveyAnswer.SurveyResponseID = UConvert.ConvertToInt32(row["SurveyResponseID"]);
                        surveyAnswer.SurveyQuestionID = UConvert.ConvertToInt32(row["SurveyQuestionID"]);
                        surveyAnswer.Comments = UConvert.ConvertToString(row["Comments"]);
                        surveyAnswer.SelectedAnswer = UConvert.ConvertToString(row["SelectedAnswer"]);
                        surveyAnswer.SelectedAnswerValue = UConvert.ConvertToInt32(row["SelectedAnswerValue"]);
 
                        surveyAnswers.Add(surveyAnswer);
                    }
                }
            }
            catch
            {
                throw;
            }
            return surveyAnswers;
        }
 
        public SurveyAnswer GetSurveyAnswer(int surveyResponseID, int surveyQuestionID) //, int surveyQuestionTypeID)
        {
            DataTable dtSurveyAnswers = null;
            SurveyAnswer surveyAnswer = new SurveyAnswer(_logger, _surveyDB);
            try
            {
                dtSurveyAnswers = _surveyDB.GetSurveyAnswer(_logger, surveyResponseID, surveyQuestionID);
                if (dtSurveyAnswers != null && dtSurveyAnswers.Rows.Count > 0)
                {
                    foreach (DataRow row in dtSurveyAnswers.Rows)
                    {
                        surveyAnswer.SurveyAnswerID = UConvert.ConvertToInt32(row["SurveyAnswerID"]);
                        surveyAnswer.SurveyResponseID = UConvert.ConvertToInt32(row["SurveyResponseID"]);
                        surveyAnswer.SurveyQuestionID = UConvert.ConvertToInt32(row["SurveyQuestionID"]);
                        surveyAnswer.Comments = UConvert.ConvertToString(row["Comments"]);
                        surveyAnswer.SelectedAnswer = UConvert.ConvertToString(row["SelectedAnswer"]);
                        surveyAnswer.SelectedAnswerValue = UConvert.ConvertToInt32(row["SelectedAnswerValue"]);
 
                        //For Radio button YES Answer
                        if (surveyAnswer.SelectedAnswerValue == 1)
                            surveyAnswer.IsYesChecked = true;
                        else
                            surveyAnswer.IsYesChecked = false;
                        //For Radio button NO Answer
                        if (surveyAnswer.SelectedAnswerValue == 0)
                            surveyAnswer.IsNoChecked = true;
                        else
                            surveyAnswer.IsNoChecked = false;
                    }
                }
            }
            catch
            {
                throw;
            }
            return surveyAnswer;
        }
 
    }
}

Thanks!

Yoan
Telerik team
 answered on 12 Sep 2019
1 answer
98 views

Hello, I'm implemented an AggregateFunction (CountFunction) in my GridView, but that decrease the perfomance of the loading drastically. Without the CountFunction, the Grid loads very fast, less than a second, and when i add the function, takes about 4-5 seconds to load the data, and, when I group a column and remove the group, it will take some seconds to load everything again.

 

<telerik:GridViewDataColumn.AggregateFunctions>
    <telerik:CountFunction Caption="Total: " />
</telerik:GridViewDataColumn.AggregateFunctions>
Vladimir Stoyanov
Telerik team
 answered on 12 Sep 2019
1 answer
246 views
01.
<telerik:RadCartesianChart Name="Chart" Grid.Row="1" >
02. 
03.            <telerik:RadCartesianChart.HorizontalAxis>
04.                <telerik:DateTimeContinuousAxis LabelFitMode="MultiLine" LabelFormat="dd-MMM-yy" SmartLabelsMode="SmartStep" Title="Date" />
05.            </telerik:RadCartesianChart.HorizontalAxis>
06.            <telerik:RadCartesianChart.VerticalAxis>
07.                <telerik:LinearAxis RangeExtendDirection="None" LabelFormat="N0" Title="VaR"/>
08.            </telerik:RadCartesianChart.VerticalAxis>
09. 
10.            <telerik:RadCartesianChart.Behaviors>
11.                <telerik:ChartTrackBallBehavior SnapMode="ClosestPoint" SnapSinglePointPerSeries="True"  >   
12.                </telerik:ChartTrackBallBehavior>      
13.            </telerik:RadCartesianChart.Behaviors>
14. 
15.            <telerik:RadCartesianChart.SeriesProvider  >
16.                <telerik:ChartSeriesProvider Source="{Binding Series}" >
17.                    <telerik:ChartSeriesProvider.SeriesDescriptors >
18. 
19.                        <telerik:CategoricalSeriesDescriptor CategoryPath="Mkt_Date" 
20.                                                        ValuePath="VaR" 
21.                                                        ItemsSourcePath="Items">
22. 
23.                            <telerik:CategoricalSeriesDescriptor.Style >
24.                                <Style TargetType="telerik:LineSeries" BasedOn="{StaticResource LineSeriesStyle}">
25.                                    <Setter Property="StrokeThickness" Value="4"></Setter>
26.                                    <Setter Property="Stroke" Value="{Binding Color}"></Setter>
27.                                                                         
28.                                    <Setter Property="TrackBallInfoTemplate" >
29.                                        <Setter.Value>
30.                                            <DataTemplate>
31.                                                <Border>
32.                                                    <StackPanel Orientation="Horizontal">
33.                                                        <Label Background="{Binding Path=DataPoint.Presenter.DataContext.Color}" Width="16" Margin="1"></Label>
34.                                                        <TextBlock Text="{Binding Path=DataPoint.Presenter.DataContext.Book}"></TextBlock>
35.                                                        <TextBlock Text=" "></TextBlock>
36.                                                        <TextBlock Text="{Binding Path=DataPoint.Value, StringFormat=N4}"></TextBlock>
37.                                                    </StackPanel>
38.                                                </Border>
39.                                            </DataTemplate>
40.                                        </Setter.Value>     
41.                                    </Setter>
42.                                     
43.                                </Style>
44.                            </telerik:CategoricalSeriesDescriptor.Style>
45.                        </telerik:CategoricalSeriesDescriptor>
46.                    </telerik:ChartSeriesProvider.SeriesDescriptors>
47.                </telerik:ChartSeriesProvider>
48.            </telerik:RadCartesianChart.SeriesProvider>
49.        </telerik:RadCartesianChart>

 

Hi,

I'm wondering is it possible to format each entry in a trackball in relation to one another? Currently I display 1 or more series in this chart view with the details of data points in each series shown using the trackball. Ideally i would like to display all the trackball information within a grid so each type of information for each data point can be aligned. 

e.g.

     |     Category       |       Value           |  

     +============+============+

     |  Datapoint1Cat  |  Datapoint1Val  |

     +============+============+
     |  Datapoint2Cat  |  Datapoint2Val  |

     +============+============+
     |  Datapoint3Cat  |  Datapoint3Val  |

etc....

Is this possible/

 Thanks!

 

Martin Ivanov
Telerik team
 answered on 12 Sep 2019
4 answers
227 views

Hi There,

Can anyone provide an example of how to catch connection 'drag & drop' events in a RadDiagram? I've bound all the connection related DnD events to a property handler but it get a hits very sporadically when moving the connections from one shape to another. The code is shown below. No doubt I'm doing something silly but I can't find any example anywhere in the docs. Any suggestions on how to get this to work are greatly appreciated.

 

Regards,

Eric G.

 

       // create some event handlers

       private void EdgeDragEnter(object sender, EventArgs e)
        {
            System.Diagnostics.Debug.WriteLine("drag enter");
        }

        .....

       // create some connections and wire them to the handlers

     var connection = new RadDiagramConnection() { Source = edgePair.Key, Target = targetInfo.node, ... TargetCapType=CapType.Arrow2Filled};
                connection.DragEnter += EdgeDragEnter;
                connection.DragLeave += EdgeDragEnter;
                connection.Drop += EdgeDragEnter;
                connection.BeginEdit += EdgeDragEnter;
                connection.EndEdit += EdgeDragEnter;
                connection.GotFocus += EdgeDragEnter;
                connection.ManipulationCompleted += EdgeDragEnter;

Martin Ivanov
Telerik team
 answered on 12 Sep 2019
2 answers
56 views

Hi,

Some of my grid cell values are unusually long. These are anomalies, so I don't want to make the affected columns wide enough to accommodate these anomalies. Instead, I'd like to use a tooltip to merely show the entire cell's value when its contents are cut off. How can I achieve this?

Wayne

n/a
Top achievements
Rank 1
 answered on 12 Sep 2019
1 answer
644 views

I am creating a Windows Service that needs to show status alerts to the user.  So, I'll put an icon in the system tray and post alerts when events happen.  Do you have a working example as to how this can be done?

Thanks for your help,

Joel

Martin Ivanov
Telerik team
 answered on 11 Sep 2019
7 answers
398 views
i want to set the center location of an ellipsedata or mapellipse view. like setting a hotspot in its middle. how is it possible. currently the location of mapellipseview and ellipsedata refer to its top left corners location.
actually my complete need is to click on somewhere on the map. draw an ellipse on that location(centered)  and as i move the mouse back and forth the radius of the ellipse gets enlarged/shortend until i again click the mouse and the ellipse is persisted in its last shape. the radius of the ellipse is the length between the first click and the second click. i must not that i cannot use the Ellipse because i need the radius to be in kilometers so that it changes with zoom changing.
Ola
Top achievements
Rank 1
 answered on 11 Sep 2019
1 answer
45 views
Is there an easy way to hide the $type Property of an ExpandoObject in the PropertyGrid? See attached screenshot.
Vladimir Stoyanov
Telerik team
 answered on 11 Sep 2019
3 answers
252 views

Hello

I use c# wpf telerik RadGridView and I have problem with Pasting. RadGridView`s cells contain my special custom type:

class Place

{

   int id;

   string name;

}

I need to get source cell in PastingCellClipboardContent to read Place.id:

private void radGridView1_PastingCellClipboardContent(object sender, GridViewCellClipboardEventArgs e){

if (e.Cell.Column.UniqueName == "Place"){

   //here i need source cell

}

How can I get it?

Thanks

Martin Ivanov
Telerik team
 answered on 11 Sep 2019
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?