Telerik Forums
UI for WPF Forum
1 answer
2.0K+ views

Hello. I'm using a RadTabControl with statically declared RadTabItems in the XAML. Within a RadTabItem, I am using a RadTabItem.HeaderTemplate to define the item's header to include an image. Immediately following the HeaderTemplate, I put a reference to another View (a UserControl). I've included the XAML for the RadWindow which contains the TabControl I am referring to below.

Here's my question. I am looking to load data when a new TabItem is selected, instead of loading data in the constructors of my VIewModels (so that I am not loading a ton of data when the app launches). So, for example, I don't want to load the data within Manifests_Home_ViewModel until the user has selected the Manifests TabItem. But, as you can see in my XAML, a reference to my UserControl 

<mainWindow:Manifests_Home_View />

is nested within the first tab item of a TabControl on my MainWindow View.  But the Manifests_Home_View doesn't know anything about the parent View (MainWindow) that is is nested in. Since the TabControl is on the MainWindow, I don't know how to inform this child/nested view that its parent TabItem has been selected.

I'm fairly new to MVVM and am still converting parts of my app properly to MVVM. I found some stuff about hierarchies with Views/ViewModels and MVVM, but that was more about dynamically generated/injected Views. These aren't dynamic as such, as they are defined up front. They are simply split out into multiple views for organization and cleared code.

Thank you for your help.

<telerik:RadWindow x:Class="TheReplacementSystem.Modules._MainWindow.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                   xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" xmlns:navigation="clr-namespace:Telerik.Windows.Controls.Navigation;assembly=Telerik.Windows.Controls.Navigation"
                   navigation:RadWindowInteropHelper.ShowInTaskbar="True" navigation:RadWindowInteropHelper.AllowTransparency="True" navigation:RadWindowInteropHelper.Icon="/ImageResources/HeaderTab/export.png"
                   navigation:RadWindowInteropHelper.Title="The New System" Header="The New System" WindowState="Maximized" Width="1920" Height="1040" HorizontalAlignment="Stretch"
                   xmlns:delivery="clr-namespace:TheReplacementSystem.Views.Delivery"
                   xmlns:mainWindow="clr-namespace:TheReplacementSystem.Modules._MainWindow"
                   Closed="MainWindow_OnClosed">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <!--<RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />-->
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <!--main Tab Control for the entire app-->
        <telerik:RadTabControl x:Name="MainAppTabControl" Grid.Row="0" Grid.Column="0" Margin="5, 5, 5, 5" Loaded="MainAppTabControl_OnLoaded" TabClosed="MainAppTabControl_OnTabClosed" AllowDragReorder="False" AllowDragOverTab="False" SelectedItemRemoveBehaviour="SelectPrevious">
            
            <!--Manifests - home tab-->
            <telerik:RadTabItem x:Name="tabItem_Manifest" Header="Manifests" Loaded="ManifestTab_OnLoaded">
                <telerik:RadTabItem.HeaderTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal">
                            <Image Source="/ImageResources/HeaderTab/manifest.png" Width="30" />
                            <telerik:Label Content="Manifest" FontWeight="Bold" />
                        </StackPanel>
                    </DataTemplate>
                </telerik:RadTabItem.HeaderTemplate>
                <mainWindow:uc_Manifests_Home />
            </telerik:RadTabItem>
            <!--Exports - home tab-->
            <telerik:RadTabItem x:Name="tabItem_Exports" Header="Exports" Loaded="ExportsTab_OnLoaded">
                <telerik:RadTabItem.HeaderTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal">
                            <Image Source="/ImageResources/HeaderTab/export.png" Width="30" />
                            <telerik:Label Content="Export" FontWeight="Bold" />
                        </StackPanel>
                    </DataTemplate>
                </telerik:RadTabItem.HeaderTemplate>
                <mainWindow:uc_Exports_Home />
            </telerik:RadTabItem>
            <!--Declarations - home tab-->
            <telerik:RadTabItem x:Name="tabItem_Declarations" Header="Declarations">
                <telerik:RadTabItem.HeaderTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal">
                            <Image Source="\ImageResources/HeaderTab/declarations.jpg" Width="30" />
                            <telerik:Label Content="Declarations" FontWeight="Bold" />
                        </StackPanel>
                    </DataTemplate>
                </telerik:RadTabItem.HeaderTemplate>
                <mainWindow:uc_Declarations_Home />
            </telerik:RadTabItem>
            <!--Billing - home tab-->
            <telerik:RadTabItem x:Name="tabItem_Billing" Header="Billing">
                <telerik:RadTabItem.HeaderTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal">
                            <Image Source="\ImageResources/HeaderTab/billing.png" Width="30" />
                            <telerik:Label Content="Billing" FontWeight="Bold" />
                        </StackPanel>
                    </DataTemplate>
                </telerik:RadTabItem.HeaderTemplate>
                <mainWindow:uc_Billing_Home />
            </telerik:RadTabItem>
            <!--Delivery - home tab-->
            <telerik:RadTabItem x:Name="tabItem_Delivery" Header="Delivery">
                <telerik:RadTabItem.HeaderTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal">
                            <Image Source="\ImageResources/HeaderTab/delivery.png" Width="30" />
                            <telerik:Label Content="Delivery" FontWeight="Bold" />
                        </StackPanel>
                    </DataTemplate>
                </telerik:RadTabItem.HeaderTemplate>
                <delivery:uc_Delivery />
            </telerik:RadTabItem>
            <!--Logistics dispatch - home tab-->
            <telerik:RadTabItem x:Name="tabItem_LogisticsDispatch" Header="Dispatch">
                <telerik:RadTabItem.HeaderTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal">
                            <Image Source="\ImageResources/HeaderTab/dispatch.jpg" Width="30" />
                            <telerik:Label Content="Dispatch" FontWeight="Bold" />
                        </StackPanel>
                    </DataTemplate>
                </telerik:RadTabItem.HeaderTemplate>
            </telerik:RadTabItem>
            <!--Data Management - home tab-->
            <telerik:RadTabItem x:Name="tabItem_DataManagement" Header="Data Management" Loaded="DataMaintenance_OnLoaded">
                <telerik:RadTabItem.HeaderTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal">
                            <Image Source="/ImageResources/HeaderTab/datamangement.png" Width="30" />
                            <telerik:Label Content="Data Management" FontWeight="Bold" />
                        </StackPanel>
                    </DataTemplate>
                </telerik:RadTabItem.HeaderTemplate>
                <mainWindow:uc_DataManagement_Home />
            </telerik:RadTabItem>
        </telerik:RadTabControl>
    </Grid>
</telerik:RadWindow>


Dilyan Traykov
Telerik team
 answered on 25 Aug 2021
1 answer
1.5K+ views

Hi,

This is bit outdated question, but I want to handle GridviewRow double click event more efficiently.

My grid view contains RowDetails template (Tab control). Row details contains summary and attachment tab. While attachment tab displays attachments in girdview control.

I had registered GridviewRow double click event in parent GridView as


private void GridView_RowLoaded(object sender, Telerik.Windows.Controls.GridView.RowLoadedEventArgs e)
        {
            if (e.Row is GridViewRow)
            {
                e.Row.AddHandler(GridViewRow.MouseDoubleClickEvent, new MouseButtonEventHandler(OnRowMouseDoubleClick), false);
            }
        }

Double click event is fired as expected but with following exception (which is not required), but as per behavior its valid.

  • Double click event triggered by double click on parent gridview header
  • Double click event triggered by double click on GridviewRow details (even scroll bar in attachment gridview)

To overcome these I added following checks


private async void OnRowMouseDoubleClick(object sender, MouseButtonEventArgs args) { FrameworkElement originalSender = args.OriginalSource as FrameworkElement; var cell = originalSender.ParentOfType<GridViewCell>(); if (cell == null) { return; } var selectedRowContext = ((System.Windows.FrameworkElement)sender).DataContext as MyDataContext; if (selectedRowContext == null) return;

}

Basically I am validating Gridview Header and RowDetails gridview scrollbar by "cell" in above example.

While I validate Row details double click by selectedRowContext as there datacontext is different from MyDataContext.

I feel that this is temporary solution. I want to fix it, i.e. double click only happens on DataRow or Data cell. All other controls in Gridview should be excluded.

 

 

 

Dilyan Traykov
Telerik team
 answered on 25 Aug 2021
1 answer
1.0K+ views

Hi team,

We are working with a requirement where user would only wants to enter date for the selection and control suggest current month and year.

Stenly
Telerik team
 answered on 24 Aug 2021
1 answer
200 views

Hello,

I want to be able to filter (and also see what I am filtering) when the IsEditable Property of the RadComboBox is false

Is there a way to set a Textblock in the Itemtemplate (like the ClearAll Button) of the RadComboBox to filter through the Items?

 

Regards,

Kai

Dilyan Traykov
Telerik team
 answered on 24 Aug 2021
2 answers
564 views

This is what it looks like in the PDfViewer.Some characters are not shown.  '成'  Unable to display。

There are characters in the document.

 

Kamran
Top achievements
Rank 3
Iron
Iron
Veteran
 answered on 24 Aug 2021
1 answer
139 views
I can see event handlers for Move and Remove a point on a connection but not for add. There's code for ConnectionManipulationStartedCommand and ConnectionManipulationCompletedCommand which gives us move and remove but is there one for adding a point?
Dinko | Tech Support Engineer
Telerik team
 answered on 23 Aug 2021
1 answer
169 views

Hi All!

I solve the problem to disable of some RadPanes to drop on a specific RadPaneGroup. RadPane groups are created in xaml with a defined Name (also Tag has been tested):

 

<telerik:RadSplitContainer InitialPosition="DockedLeft">
        <telerik:RadPaneGroup x:Name="Left"/>
</telerik:RadSplitContainer>

In a custom docking panes factory the each RadPane (Tag contains position - string, e.g. Left) is correctly added into the specific RadPaneGroup based on the Name specified above. All the RadPanes are correctly added.

protected override void AddPane(Telerik.Windows.Controls.RadDocking radDocking, Telerik.Windows.Controls.RadPane pane) { var tag = pane.Tag.ToString(); if (radDocking.SplitItems.ToList().FirstOrDefault(i => i.Control.Name.Contains(tag)) is RadPaneGroup paneGroup) { paneGroup.Items.Add(pane); } else { base.AddPane(radDocking, pane);

} }

 

OnPreviewShowCompass event is used to allow a RadPane to drop on a specific RadPaneGroup. However, in the argument of this method (PreviewShowCompassEventArgs e) the Name property in e.TargetGroup is empty. But a given TargetGroup (RadPaneGroup) contains the correct number and types of RadPanes.
I cannot understand why Name property is empty, it should be specified based on xaml and a reference to this should be taken.

Thank you.

Radek

 

 

Vladimir Stoyanov
Telerik team
 answered on 23 Aug 2021
2 answers
215 views

Hi!

I would like to have a scatterpoint series with horizontal lines as point template.

Moste important: the width of these horizontal lines must be the width of the ticks on the horizontal axis.

It is supposed to look like a StepLineChart where the verticalrisers are transparent so to speak, so the horizontals forms steps.

 

David
Top achievements
Rank 1
Iron
 answered on 23 Aug 2021
2 answers
318 views

Have a RadGridview that allows multiple selections. Currently only allowing rows.

<telerik:RadGridView x:Name="gvMrsUserSettings"
                                 Background="Black"
                                 FontFamily="Arial"
                                 Foreground="White"
                                 FontSize="11"
                                 GroupRenderMode="Flat"
                                 ItemsSource="{Binding MrsUserDataTable}"
                                 SelectionMode="Extended"
                                 AutoGenerateColumns="True"
                                 Margin="0,0,0,0"
                                 Grid.Row="1"
                                 ActionOnLostFocus="None"
                                 CanUserFreezeColumns="False"
                                 RowIndicatorVisibility="Collapsed"
                                 ShowGroupPanel="False"
                                 IsFilteringAllowed="True"
                                 ShowSearchPanel="True"
                                 SearchPanelCloseButtonVisibility="Collapsed"
                                 IsReadOnly="True"
                                 CanUserReorderColumns="False"
                                 CanUserDeleteRows="False"
                                 CanUserInsertRows="False"
                                 CanUserGroupColumns="False"
                                 CanUserSearch="False"
                                 CanUserSortGroups="False"
                                 EnableColumnGroupsVirtualization="False"
                                 ClipboardCopyMode="All,Header"
                                 ClipboardPasteMode="Cells,AllSelectedRows"
                                 IsBusy="False"
                                 >

If you select row 1, 4, 6 - 10 and 20, do a Ctrl+C then a Ctrl+V in a text file or excel all the rows between the numbers are blank.

Not sure what feature needs to be included in the XAML to prevent this behavior. Or what must be done short of modifying the collection in the clipboard.

sample of result is:

GROUP
UTI-KELLER
 
 
CLK_FINANCE
 
EMS_FIRE
CEL
COURT_ADMIN
COURT_ADMIN
COURT_ADMIN
 
 
 
 
 
 
 
 
 
UTILITIES

 

 

herb
Top achievements
Rank 1
Veteran
Iron
 answered on 21 Aug 2021
1 answer
176 views

Does the RadTimeBar support when Windows has a non-Gregorian calendar set? Specifically this one: https://docs.microsoft.com/en-us/dotnet/api/system.globalization.umalquracalendar?view=net-5.0. I get an exception that says this when I change my Windows settings to get that calendar:

Exception Stack Trace: System.Windows.Markup.XamlParseException: Specified time is not supported in this calendar. It should be between 04/30/1900 00:00:00 (Gregorian date) and 11/16/2077 23:59:59 (Gregorian date), inclusive.

I can reproduce it with XAML as simple as this:

		<telerik:RadTimeBar x:Name="TimeBar"
                            PeriodStart="1-Jan-2019 12:00:00 AM"
                            PeriodEnd="31-Dec-2019 11:59:59 PM"
                            VisiblePeriodStart="14-March-2019 12:00:00 AM"
                            VisiblePeriodEnd="11-Nov-2019 11:59:59 PM">
			<telerik:RadTimeBar.Intervals>
				<telerik:YearInterval />
				<telerik:MonthInterval />
				<telerik:WeekInterval />
				<telerik:DayInterval />
			</telerik:RadTimeBar.Intervals>
		</telerik:RadTimeBar>


Stenly
Telerik team
 answered on 20 Aug 2021
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?