Reusable DataTemplate. How to specify? Need syntax assistance - c#

This is my control with my custom DataTemplateSelector:
<m:Map x:Name="MainMap">
<m:MapItemsControl
ItemsSource="{Binding Source={StaticResource WorkLayerData}}">
<m:MapItemsControl.ItemTemplate>
<DataTemplate>
<Mobile:DevicePushpinTemplateSelector
m:MapLayer.Position="{Binding Location}"
ZoomLevel="{Binding ZoomLevel, ElementName=MainMap}"
Content="{Binding}">
<Mobile:DevicePushpinTemplateSelector.DotTemplate>
<DataTemplate>
<Ellipse Width="8" Height="8" Stroke="Black" Fill="{Binding IsGPSDataRecent, Converter={StaticResource BoolToGreenRedBrushConverter}}" StrokeThickness="1" />
</DataTemplate>
</Mobile:DevicePushpinTemplateSelector.DotTemplate>
<Mobile:DevicePushpinTemplateSelector.NumberedTemplate>
<DataTemplate>
<Border x:Name="border" Background="{Binding IsGPSDataRecent, Converter={StaticResource BoolToGreenRedBrushConverter}}" BorderBrush="Black" BorderThickness="2" Padding="2" Height="20" CornerRadius="8">
<TextBlock VerticalAlignment="Center" Text="{Binding DisplayId}" />
</Border>
</DataTemplate>
</Mobile:DevicePushpinTemplateSelector.NumberedTemplate>
<Mobile:DevicePushpinTemplateSelector.DetailedTemplate>
<DataTemplate>
<Border Background="{Binding IsGPSDataRecent, Converter={StaticResource BoolToGreenRedBrushConverter}}" BorderBrush="Black" BorderThickness="1" Padding="2" CornerRadius="2">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock Text="Id:" FontWeight="Bold" />
<TextBlock Text="{Binding DisplayId}" Grid.Column="1" />
<TextBlock Text="Device Id:" FontWeight="Bold" Grid.Row="1" />
<TextBlock Text="{Binding DeviceId}" Grid.Row="1" Grid.Column="1" />
<TextBlock Text="Speed:" FontWeight="Bold" Grid.Row="2" />
<TextBlock Text="{Binding Speed}" Grid.Row="2" Grid.Column="1" />
<TextBlock Text="Location:" FontWeight="Bold" Grid.Row="3" />
<TextBlock Text="{Binding Location}" Grid.Row="3" Grid.Column="1" />
<Button Content="View Details" Grid.Row="4" Grid.ColumnSpan="2" />
</Grid>
</Border>
</DataTemplate>
</Mobile:DevicePushpinTemplateSelector.DetailedTemplate>
</Mobile:DevicePushpinTemplateSelector>
</DataTemplate>
</m:MapItemsControl.ItemTemplate>
</m:MapItemsControl>
</m:Map>
I want to move my Mobile:DevicePushpinTemplateSelector.DetailedTemplate into resources so I can reuse it somewhere else.
I declared resource:
<UserControl.Resources>
<DataTemplate x:Key="DetailedMapItemTemplate">
<Border Background="{Binding IsGPSDataRecent, Converter={StaticResource BoolToGreenRedBrushConverter}}" BorderBrush="Black" BorderThickness="1" Padding="2" CornerRadius="2">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock Text="Id:" FontWeight="Bold" />
<TextBlock Text="{Binding DisplayId}" Grid.Column="1" />
<TextBlock Text="Device Id:" FontWeight="Bold" Grid.Row="1" />
<TextBlock Text="{Binding DeviceId}" Grid.Row="1" Grid.Column="1" />
<TextBlock Text="Speed:" FontWeight="Bold" Grid.Row="2" />
<TextBlock Text="{Binding Speed}" Grid.Row="2" Grid.Column="1" />
<TextBlock Text="Location:" FontWeight="Bold" Grid.Row="3" />
<TextBlock Text="{Binding Location}" Grid.Row="3" Grid.Column="1" />
<Button Content="View Details" Grid.Row="4" Grid.ColumnSpan="2" />
</Grid>
</Border>
</DataTemplate>
</UserControl.Resources>
My problem is that I don't know HOW to use this DataTemplate inside my selector. What is the XAML I need to use? With controls like ListBox it is easy, just set ItemTemplate="{StaticResource thisTemplate}" but how do I do this in my case? Still learning XAML

Just set the DetailedTemplate property in the tag itself:
<Mobile:DevicePushpinTemplateSelector
m:MapLayer.Position="{Binding Location}"
ZoomLevel="{Binding ZoomLevel, ElementName=MainMap}"
Content="{Binding}"
DetailedTemplate="{StaticResource DetailedMapItemTemplate}">
...

Related

WPF XAML resize <infrastructure:Plugin> width to the content in it

I have an interface with some tabs in it on the right side of the screen. I need each tab`s width to be resized by width of the context in it.
All the other tabs do it apart from this one...
Any suggestions, please?
Description
The scales tab in the stackup editor doesn’t resize when selected.
Select the scales tab on the right side of the stackup editor
Right hand tab doesn’t resize
Expected Behaviour
Tab resizes to fit content, as with all other tabs in the stackup
editor
enter image description here
<infrastructure:Plugin x:Class="Xact.GeminiX.Plugin.PanelEditors.Views.DisplayScalesView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:infrastructure="clr-namespace:Xact.GeminiX.Client.Common.Infrastructure;assembly=Xact.GeminiX.Client.Common"
xmlns:converters="clr-namespace:Xact.GeminiX.Client.Wpf.Common.Converters;assembly=Xact.GeminiX.Client.Wpf.Common"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
LayoutUpdated="ViewLayoutUpdated"
Loaded="Plugin_Loaded">
<infrastructure:Plugin.Resources>
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"></BooleanToVisibilityConverter>
<converters:BooleanToVisibilityHiddenOnFalseConverter x:Key="BooleanToVisibilityHiddenOnFalseConverter"></converters:BooleanToVisibilityHiddenOnFalseConverter>
<infrastructure:DataContextProxy x:Key="DataContextProxy"/>
</infrastructure:Plugin.Resources>
<i:Interaction.Behaviors>
<infrastructure:DataContextProxyBehavior DataContextProxy="{StaticResource DataContextProxy}"/>
</i:Interaction.Behaviors>
<Grid Grid.IsSharedSizeScope="True" PreviewMouseWheel="UIElement_OnPreviewMouseWheel">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="Auto"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.Resources>
<ContextMenu x:Key="ImportContextMenu"
ItemsSource="{Binding DataContext.ScalingImportExportMetaData.ScalingImportFormats, Source={StaticResource DataContextProxy}}">
<ContextMenu.ItemContainerStyle>
<Style TargetType="MenuItem">
<Setter Property="Header"
Value="{Binding FormatTitle}"/>
<Setter Property="Command"
Value="{Binding DataContext.FormatSelectionCommand, Source={StaticResource DataContextProxy}}"/>
<Setter Property="CommandParameter"
Value="{Binding}"/>
</Style>
</ContextMenu.ItemContainerStyle>
</ContextMenu>
<ContextMenu x:Key="ImportFromStackupContextMenu">
<MenuItem Header="{Binding StoredLocalisation}" Click="ButtonImportFromStackupStored_OnClick"/>
<MenuItem Header="{Binding RemakesLocalisation}" Click="ButtonImportFromStackupRemakes_OnClick"/>
</ContextMenu>
<ContextMenu x:Key="ContextMenu" ItemsSource="{Binding DataContext.ScalingImportExportMetaData.ScalingExportFormats, Source={StaticResource DataContextProxy}}">
<ContextMenu.ItemContainerStyle>
<Style TargetType="MenuItem">
<Setter Property="Header"
Value="{Binding FormatTitle}"/>
<EventSetter Event="Click"
Handler="MenuItem_OnClick"/>
</Style>
</ContextMenu.ItemContainerStyle>
</ContextMenu>
<DataTemplate x:Key="ExportButtonTemplate">
<telerik:RadButton Content="{Binding TypeTitle}" Click="ButtonBase_OnClick" IsEnabled="{Binding Enabled}" ContextMenu="{StaticResource ContextMenu}" Margin="2"/>
</DataTemplate>
</Grid.Resources>
<ScrollViewer VerticalScrollBarVisibility="Disabled"
HorizontalScrollBarVisibility="Auto"
HorizontalAlignment="Left"
HorizontalContentAlignment="Left"
Grid.Column="0">
<Grid>
<Grid.Resources>
<converters:BooleanInvertConverter x:Key="BooleanInvertConverter"></converters:BooleanInvertConverter>
</Grid.Resources>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" SharedSizeGroup="B"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto" SharedSizeGroup="C"/>
<RowDefinition Height="Auto" SharedSizeGroup="D"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0" Loaded="TopGrid_OnLoaded" HorizontalAlignment="Left" x:Name="Grid">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" SharedSizeGroup="A" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" Text="{Binding LayerLocalisation}" Margin="5" />
<TextBlock Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="2" Text="{Binding FirstScaleFactorLocalisation}" HorizontalAlignment="Center" Margin="5" />
<TextBlock Grid.Row="0" Grid.Column="3" Grid.ColumnSpan="2" Text="{Binding SecondScaleFactorLocalisation}" HorizontalAlignment="Center" Margin="5" />
<TextBlock Grid.Row="1" Grid.Column="1" Text="{Binding ArtworkLocalisation}" HorizontalAlignment="Center" Margin="5" />
<TextBlock Grid.Row="1" Grid.Column="2" Text="{Binding PredictedLocalisation}" HorizontalAlignment="Center" Margin="5" />
<TextBlock Grid.Row="1" Grid.Column="3" Text="{Binding ArtworkLocalisation}" HorizontalAlignment="Center" Margin="5" />
<TextBlock Grid.Row="1" Grid.Column="4" Text="{Binding PredictedLocalisation}" HorizontalAlignment="Center" Margin="5" />
<Border Grid.Row="2"
Grid.Column="0"
Grid.ColumnSpan="5"
BorderThickness="0, 1, 0, 0"
Margin="0, 5, 0, 5"
BorderBrush="LightGray" />
<TextBlock Grid.Row="3"
Grid.Column="0"
Text="{Binding AllLocalisation}"
VerticalAlignment="Center"
Margin="5" />
<TextBox x:Name="EnabledTemplate"
Grid.Row="3"
Grid.Column="1"
Margin="5"
Text="{Binding ShortValue, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
KeyDown="SetShortValues_OnKeyDown"
TextChanged="ShortValueTextbox_TextChanged"
Width="80"
IsEnabled="{Binding ScalesExist}"
MaxLength="10" />
<telerik:RadButton Grid.Row="3"
Grid.Column="2"
Content="{Binding SetFirstLocalisation}"
Click="SetShortButton_OnClick"
IsEnabled="{Binding ScalesExist}"
Margin="2"/>
<TextBox Grid.Row="3"
Grid.Column="3"
Margin="5"
Text="{Binding LongValue, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
KeyDown="SetLongValues_OnKeyDown"
TextChanged="ShortValueTextbox_TextChanged"
Width="80"
IsEnabled="{Binding ScalesExist}"
MaxLength="10" />
<telerik:RadButton Grid.Row="3"
Grid.Column="4"
Content="{Binding SetSecondLocalisation}"
Click="SetLongButton_OnClick"
IsEnabled="{Binding ScalesExist}"
Margin="2"/>
<CheckBox Grid.Row="4"
Grid.Column="0"
IsEnabled="{Binding ScalesExist}"
IsChecked="{Binding AllCheckboxIsChecked}"
Margin="5"
Click="SetAllCheckBoxToggled" />
<telerik:RadButton Grid.Row="4"
Grid.Column="2"
Content="{Binding PredictedSwapLocalisation}"
Click="PredictedShortButton_OnClick"
IsEnabled="{Binding PredictionsAvailable}"
AutomationProperties.AutomationId="PredictedShortButtonID"
x:Name="PredictedShortButtonID"
Margin="2"/>
<telerik:RadButton Grid.Row="4"
Grid.Column="4"
Content="{Binding PredictedSwapLocalisation}"
Click="PredictedLongButton_OnClick"
IsEnabled="{Binding PredictionsAvailable}"
AutomationProperties.AutomationId="PredictedLongButtonID"
x:Name="PredictedLongButtonID"
Margin="2"/>
<Border Grid.Row="5" Grid.Column="0" Grid.ColumnSpan="5" BorderThickness="0, 1, 0, 0" Margin="0, 10, 0, 10" BorderBrush="LightGray" />
</Grid>
<Grid Grid.Row="1">
<ScrollViewer HorizontalAlignment="Left" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Hidden" Name="ScrollViewer" ScrollChanged="ScrollViewer_OnScrollChanged">
<Grid>
<Grid.Resources>
<DataTemplate x:Key="RowsTemplate">
<Grid x:Name="TemplateGrid">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" SharedSizeGroup="A" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid Grid.Column="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<CheckBox Grid.Column="0" IsChecked="{Binding IsChecked}" VerticalAlignment="Center" Margin="5" IsEnabled="{Binding Editable}"
Command="{Binding Path=DataContext.CheckBoxChangedCommand, ElementName=Grid}" CommandParameter="{Binding}" />
<TextBlock Grid.Column="1" Text="{Binding Layer}" VerticalAlignment="Center" Margin="5" />
</Grid>
<TextBox Grid.Column="1"
Text="{Binding ShortDisplayValue, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
IsEnabled="{Binding Editable}"
Width="80"
Margin="5"
TextChanged="ShortValueTextbox_TextChanged"
KeyDown="FirstUIElement_OnKeyDown"
LostFocus="FirstUIElement_OnLostFocus" />
<telerik:RadButton Grid.Column="2"
Command="{Binding Path=DataContext.SetSinglePredictedShortCommand, ElementName=Grid}"
CommandParameter="{Binding}"
IsEnabled="{Binding Editable}"
Visibility="{Binding Visible}" HorizontalContentAlignment="Left"
Margin="2">
<telerik:RadButton.Content>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
<Label Background="{Binding ConfidenceBrush}" Foreground="{Binding ConfidenceForegroundBrush}" Height="20" Width="20" Content="{Binding ConfidenceCharacter}" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Margin="0"></Label>
<TextBlock Text="{Binding ShortButton}" />
</StackPanel>
</telerik:RadButton.Content>
</telerik:RadButton>
<TextBox Grid.Column="3"
Text="{Binding LongDisplayValue, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
IsEnabled="{Binding Editable}"
Width="80"
Margin="5"
TextChanged="ShortValueTextbox_TextChanged"
KeyDown="SecondUIElement_OnKeyDown"
LostFocus="SecondUIElement_OnLostFocus" />
<telerik:RadButton Grid.Column="4"
Command="{Binding Path=DataContext.SetSinglePredictedLongCommand, ElementName=Grid}"
CommandParameter="{Binding}"
IsEnabled="{Binding Editable}"
Visibility="{Binding Visible}" HorizontalContentAlignment="Left"
Margin="2">
<telerik:RadButton.Content>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
<Label Background="{Binding ConfidenceBrush}" Foreground="{Binding ConfidenceForegroundBrush}" Height="20" Width="20" Content="{Binding ConfidenceCharacter}" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Margin="0"></Label>
<TextBlock Text="{Binding LongButton}" />
</StackPanel>
</telerik:RadButton.Content>
</telerik:RadButton>
</Grid>
</DataTemplate>
</Grid.Resources>
<ItemsControl ItemTemplate="{StaticResource RowsTemplate}" ItemsSource="{Binding Rows}" />
</Grid>
</ScrollViewer>
</Grid>
<Border Grid.Row="2" BorderThickness="0, 1, 0, 0" Margin="0, 0, 0, 10" BorderBrush="LightGray" />
<Grid Grid.Row="3" HorizontalAlignment="Center">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" SharedSizeGroup="A" />
<ColumnDefinition SharedSizeGroup="A" />
<ColumnDefinition SharedSizeGroup="A" />
<ColumnDefinition SharedSizeGroup="A" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
<telerik:RadButton Grid.Row="0" Grid.Column="0"
Content="{Binding SwapAllLocalisation}"
Click="SwapAllButton_OnClick"
IsEnabled="{Binding ScalesExist}"
HorizontalAlignment="Center"
Margin="2"/>
<telerik:RadButton Grid.Row="0" Grid.Column="1"
Content="{Binding SetAllPredictedLocalisation}"
Click="SetAllPredictedButton_OnClick"
IsEnabled="{Binding PredictionsAvailable}"
HorizontalAlignment="Center"
Margin="2"/>
<telerik:RadButton Grid.Row="0" Grid.Column="2"
Content="{Binding ResetLocalisation}"
Click="ResetButton_OnClick"
IsEnabled="{Binding ScalesExist}"
HorizontalAlignment="Center"
Margin="2"/>
<telerik:RadButton Grid.Row="0" Grid.Column="3"
Content="{Binding ArtworkRevisionsLocalisation}"
Click="ArtworkRevisionsButton_OnClick"
HorizontalAlignment="Center"
IsEnabled="{Binding ArtworksButtonEnabled}"
Visibility="{Binding ArtworksButtonVisible, Converter={ StaticResource BooleanToVisibilityHiddenOnFalseConverter}}"
Margin="2"/>
<telerik:RadButton Grid.Row="1" Grid.Column="0"
Content="{Binding ImportLocalisation}"
Click="ButtonImport_Click"
IsEnabled="{Binding ScalesExist}"
ContextMenu="{StaticResource ImportContextMenu}"
HorizontalAlignment="Center"
Margin="2"/>
<telerik:RadButton Grid.Row="1" Grid.Column="1"
Content="{Binding StackupImportLocalisation}"
Click="ButtonImportFromStackup_OnClick"
ContextMenu="{StaticResource ImportFromStackupContextMenu}"
IsEnabled="{Binding CanImportFromStackup}"
Visibility="{Binding ImportFromStackupEnabled, Converter={StaticResource BooleanToVisibilityConverter}}"
HorizontalAlignment="Center"
Margin="2"/>
<ItemsControl Grid.Row="1" Grid.Column ="2" Grid.ColumnSpan="2" ItemsSource="{Binding ScalingImportExportMetaData.ScalingExportTypes}" ItemTemplate="{StaticResource ExportButtonTemplate}" >
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
<Grid Grid.Row="2" Grid.Column="0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Grid.ColumnSpan="4">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition Width="Auto"></ColumnDefinition>
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" Orientation="Horizontal">
<TextBlock Text="{Binding SingleCoresLocalisation}" VerticalAlignment="Center"/>
<RadioButton IsChecked="{Binding UseSingleCores}" VerticalAlignment="Center"/>
</StackPanel>
<StackPanel Grid.Column="1" Orientation="Horizontal">
<TextBlock Text="{Binding IndividualCopperLocalisation}" VerticalAlignment="Center"/>
<RadioButton IsChecked="{Binding UseSingleCores, Converter={ StaticResource BooleanInvertConverter}}" VerticalAlignment="Center"/>
</StackPanel>
</Grid>
</Grid>
</Grid>
</ScrollViewer>
<Grid Grid.Column="1">
<Grid.Resources>
<converters:NonZeroDoubleToVisibilityConverter x:Key="NonZeroDoubleToVisibilityConverter" />
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition SharedSizeGroup="B"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition SharedSizeGroup="C"></RowDefinition>
<RowDefinition SharedSizeGroup="D"></RowDefinition>
</Grid.RowDefinitions>
<ScrollBar Grid.Row="1" Minimum="0" SmallChange="1" LargeChange="10"
ViewportSize="{Binding ViewportHeight, ElementName=ScrollViewer}"
Maximum="{Binding ScrollableHeight, ElementName=ScrollViewer}"
Scroll="ScrollBar_OnScroll" Name="ScrollBar"
Visibility="{Binding RelativeSource={RelativeSource Self}, Path=Maximum, Converter={StaticResource NonZeroDoubleToVisibilityConverter}}" />
</Grid>
</Grid>
</infrastructure:Plugin>

Scrollbar issues with WPF

In the following XAML I have two issues, the first is that despite disabling the horizontal scrollbar on the main scrollviewer it still shows, the second is that I have set a style on the textbox (notes) to display a vertical scrollbar but it does not display
<UserControl x:Class="VTUK.Gemini.Contacts.ContactsDetails"
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:telerik="http://schemas.telerik.com/2008/xaml/presentation"
xmlns:views="clr-namespace:VTUK.Gemini.Contacts"
mc:Ignorable="d"
d:DesignHeight="1200" d:DesignWidth="1200">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/VTUK.Gemini.Infrastructure;component/Styles/Brushes.xaml"/>
<ResourceDictionary Source="pack://application:,,,/VTUK.Gemini.Infrastructure;component/Styles/CommonStyles.xaml"/>
</ResourceDictionary.MergedDictionaries>
<DataTemplate x:Key="ContactsReadOnlyTemplate">
<Grid Name="Grid">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel Name="HeaderPanel" Orientation="Horizontal">
<Border BorderThickness="2" BorderBrush="{StaticResource Windows8BlueBrush}" Margin="5" >
<!--Phone3 is here as a temporary value-->
<telerik:RadTransitionControl Margin="5" Content="{Binding Phone3, FallbackValue='pack://application:,,,/VTUK.Gemini.Infrastructure;component/Images/businessperson2.png', Converter={StaticResource ImageSourceToBitmapConverter}}" Duration="0:0:1" IsTabStop="False">
<telerik:RadTransitionControl.Transition>
<!--<telerik:MotionBlurredZoomTransition/>-->
<telerik:FlipWarpTransition/>
</telerik:RadTransitionControl.Transition>
<telerik:RadTransitionControl.ContentTemplate>
<DataTemplate>
<Image Source="{Binding .}" Width="64" Height="64" />
</DataTemplate>
</telerik:RadTransitionControl.ContentTemplate>
</telerik:RadTransitionControl>
</Border>
</StackPanel>
<ScrollViewer x:Name="ScrollViewer" Width="{Binding ElementName=LayoutRoot, Path=ActualWidth}" Grid.Row="1" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto" BorderThickness="0">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="10" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" MinHeight="45" />
<RowDefinition Height="Auto" MinHeight="28" />
<RowDefinition Height="Auto" MinHeight="28" />
<RowDefinition Height="Auto" MinHeight="28" />
<RowDefinition Height="Auto" MinHeight="28" />
<RowDefinition Height="Auto" MinHeight="28" />
<RowDefinition Height="Auto" MinHeight="28" />
<RowDefinition Height="Auto" MinHeight="28" />
<RowDefinition Height="Auto" MinHeight="28" />
<RowDefinition Height="Auto" MinHeight="28" />
<RowDefinition Height="Auto" MinHeight="28" />
<RowDefinition Height="Auto" MinHeight="28" />
<RowDefinition Height="Auto" MinHeight="45" />
<RowDefinition Height="Auto" MinHeight="28" />
<RowDefinition Height="Auto" MinHeight="28" />
<RowDefinition Height="Auto" MinHeight="28" />
<RowDefinition Height="Auto" MinHeight="28" />
</Grid.RowDefinitions>
<TextBlock Text="DISPLAY NAME" Style="{StaticResource Heading14}" />
<TextBlock Text="TITLE" Style="{StaticResource Heading14}" Grid.Row="1" Grid.Column="0" />
<TextBlock Text="FORENAME" Style="{StaticResource Heading14}" Grid.Row="2" Grid.Column="0"/>
<TextBlock Text="SURNAME" Style="{StaticResource Heading14}" Grid.Row="3" Grid.Column="0"/>
<TextBlock Text="HOUSE NAME / NO." Style="{StaticResource Heading14}" Grid.Row="4" Grid.Column="0"/>
<TextBlock Text="ADDRESS1" Style="{StaticResource Heading14}" Grid.Row="5" Grid.Column="0"/>
<TextBlock Text="ADDRESS2" Style="{StaticResource Heading14}" Grid.Row="6" Grid.Column="0"/>
<TextBlock Text="TOWN" Style="{StaticResource Heading14}" Grid.Row="7" Grid.Column="0"/>
<TextBlock Text="COUNTY" Style="{StaticResource Heading14}" Grid.Row="8" Grid.Column="0"/>
<TextBlock Text="COUNTRY" Style="{StaticResource Heading14}" Grid.Row="9" Grid.Column="0"/>
<TextBlock Text="POSTCODE" Style="{StaticResource Heading14}" Grid.Row="10" Grid.Column="0"/>
<TextBlock Text="EMAIL" Style="{StaticResource Heading14}" Grid.Row="11" Grid.Column="0"/>
<TextBlock Text="PHONE !" Style="{StaticResource Heading14}" Grid.Row="12" Grid.Column="0"/>
<TextBlock Text="PHONE 2" Style="{StaticResource Heading14}" Grid.Row="13" Grid.Column="0"/>
<TextBlock Text="PHONE 3" Style="{StaticResource Heading14}" Grid.Row="14" Grid.Column="0"/>
<TextBlock Text="URL" Style="{StaticResource Heading14}" Grid.Row="15" Grid.Column="0"/>
<TextBlock Text="NOTES" Style="{StaticResource Heading14}" Grid.Row="16" Grid.Column="0" VerticalAlignment="Top"/>
<TextBlock Text="{Binding DisplayName}" TextWrapping="Wrap" FontSize="22" FontWeight="DemiBold" Grid.Row="0" Grid.Column="2" VerticalAlignment="Center" />
<TextBlock Text="{Binding Title}" Style="{StaticResource Text14}" TextWrapping="Wrap" Grid.Column="2" Grid.Row="1" />
<TextBlock Text="{Binding Forename}" Style="{StaticResource Text14}" TextWrapping="Wrap" Grid.Column="2" Grid.Row="2" />
<TextBlock Text="{Binding Surname}" Style="{StaticResource Text14}" TextWrapping="Wrap" Grid.Column="2" Grid.Row="3" />
<TextBlock Text="{Binding HouseNameNo}" Style="{StaticResource Text14}" TextWrapping="Wrap" Grid.Column="2" Grid.Row="4" />
<TextBlock Text="{Binding Address1}" Style="{StaticResource Text14}" TextWrapping="Wrap" Grid.Column="2" Grid.Row="5" />
<TextBlock Text="{Binding Address2}" Style="{StaticResource Text14}" TextWrapping="Wrap" Grid.Column="2" Grid.Row="6" />
<TextBlock Text="{Binding Town, Converter={StaticResource StringToUpperCaseConverter}}" Style="{StaticResource Text14}" TextWrapping="Wrap" Grid.Column="2" Grid.Row="7" />
<TextBlock Text="{Binding County, Converter={StaticResource StringToUpperCaseConverter}}" Style="{StaticResource Text14}" TextWrapping="Wrap" Grid.Column="2" Grid.Row="8" />
<TextBlock Text="{Binding Country, Converter={StaticResource StringToUpperCaseConverter}}" Style="{StaticResource Text14}" TextWrapping="Wrap" Grid.Column="2" Grid.Row="9" />
<TextBlock Text="{Binding Postcode, Converter={StaticResource StringToUpperCaseConverter}}" Style="{StaticResource Text14}" TextWrapping="Wrap" Grid.Column="2" Grid.Row="10" />
<TextBlock Text="{Binding Email}" Style="{StaticResource Text14}" TextWrapping="Wrap" Grid.Column="2" Grid.Row="11" />
<TextBlock Text="{Binding Phone1}" TextWrapping="Wrap" FontSize="22" FontWeight="DemiBold" Grid.Column="2" Grid.Row="12" VerticalAlignment="Center" />
<TextBlock Text="{Binding Phone2}" Style="{StaticResource Text14}" TextWrapping="Wrap" Grid.Column="2" Grid.Row="13" />
<TextBlock Text="{Binding Phone3}" Style="{StaticResource Text14}" TextWrapping="Wrap" Grid.Column="2" Grid.Row="14" />
<TextBlock x:Name="URLContainer" Text="http://www.google.com" Visibility="Collapsed" />
<telerik:RadButton x:Name="linkButton"
VerticalAlignment="Center"
Margin="0"
Content="{Binding Text, ElementName=URLContainer}"
Grid.Column="2" Grid.Row="15"
Style="{StaticResource HyperlinkStyleButton14}"
Command="{Binding NavigateToUrlCommand}" CommandParameter="{Binding Text, ElementName=URLContainer}"
DataContext="{Binding DataContext, RelativeSource={RelativeSource AncestorType=views:ContactsContent, AncestorLevel=1}}" />
<TextBox Grid.Column="2" Grid.Row="16"
Text="{Binding ContactNotes}"
Style="{DynamicResource CustomTextBoxStyle}" />
<!--Visibility="{Binding ContactNotes, Converter={StaticResource StringToVisibilityConverter}}" />-->
</Grid>
</ScrollViewer>
</Grid>
</DataTemplate>
</ResourceDictionary>
</UserControl.Resources>
<Grid x:Name="LayoutRoot">
<telerik:RadDataForm x:Name="DataForm"
ItemsSource="{Binding Contacts}"
CommandButtonsVisibility="Cancel,Commit"
AutoGenerateFields="False"
ValidationSummaryVisibility="Visible"
LabelPosition="Above"
ReadOnlyTemplate="{StaticResource ContactsReadOnlyTemplate}"
VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch" />
<StackPanel HorizontalAlignment="Right" VerticalAlignment="Top" Orientation="Horizontal">
<telerik:RadButton RenderTransformOrigin="0.5,0.5" Margin="0,0,40,0" Tag="ADD"
Command="telerik:RadDataFormCommands.AddNew" CommandTarget="{Binding ElementName=DataForm}">
<Path Stretch="None" Data="M6,0 L10,0 L10,6 L16,6 L16,10 L10,10 L10,16 L6,16 L6,10 L0,10 L0,6 L6,6 z"
SnapsToDevicePixels="True" />
</telerik:RadButton>
<telerik:RadButton Command="telerik:RadDataFormCommands.BeginEdit" CommandTarget="{Binding ElementName=DataForm}" Tag="EDIT">
<Path Stretch="Fill" Data="F1 M233.5498,613.749 C233.9048,613.662,233.9828,613.379,233.7238,613.123 L232.1378,611.544 C231.8808,611.288,231.5968,611.367,231.5098,611.718L230.9968,613.784C230.9088,614.139,231.1258,614.355,231.4808,614.267z M249.4978,595.808C247.7348,594.047,245.9968,595.404,245.9968,595.404C245.7078,595.627,245.2668,596.019,245.0118,596.269C244.7588,596.521,244.7638,596.939,245.0198,597.196L248.1078,600.281C248.3648,600.54,248.7828,600.544,249.0388,600.29C249.2918,600.036,249.6808,599.594,249.9038,599.307C249.9038,599.307,251.2638,597.572,249.4978,595.808 M237.2018,612.109C236.9458,612.369,236.5228,612.369,236.2668,612.109L233.1778,609.025C232.9208,608.768,232.9208,608.349,233.1778,608.09L243.0538,598.228C243.3108,597.971,243.7318,597.971,243.9898,598.228L247.0738,601.312C247.3328,601.571,247.3328,601.993,247.0738,602.248z"
Height="16" Width="16"
SnapsToDevicePixels="True" />
</telerik:RadButton>
</StackPanel>
<telerik:RadBusyIndicator IsIndeterminate="True"
IsBusy="{Binding IsBusy}" DisplayAfter="0:0:0.2"
telerik:AnimationManager.IsAnimationEnabled="True"/>
</Grid>
</UserControl>
<!-- Texybox with scrollviewer-->
<Style x:Key="CustomTextBoxStyle" TargetType="TextBox">
<Setter Property="Background" Value="{x:Null}" />
<Setter Property="BorderBrush" Value="{x:Null}" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="TextWrapping" Value="Wrap" />
<Setter Property="VerticalContentAlignment" Value="Top" />
<Setter Property="FontSize" Value="14" />
<Setter Property="Margin" Value="0" />
<Setter Property="Padding" Value="0" />
<Setter Property="IsReadOnly" Value="True" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="TextBox">
<Grid x:Name="RootElement" UseLayoutRounding="True">
<ScrollViewer x:Name="PART_ContentHost"
Padding="{TemplateBinding Padding}"
Foreground="{TemplateBinding Foreground}"
Background="{x:Null}"
BorderBrush="{x:Null}"
BorderThickness="0"
Margin="0"
VerticalScrollBarVisibility="Visible" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

Data Grid Template [WPF]

how this type of data grid template can be created??
i can't find any way to make this template.
or can u suggest other way??
i.e. grid view or so and how!
The last column are not required as of now.
CodeBehind:
var pp = from asd in db.OrderMasters
select new
{
asd.CFN,
asd.Location,
asd.CreatedOn,
asd.Quantity
};
dgOrderMaster.ItemsSource = pp.ToList();
Markup:
<DataGrid x:Name="dgOrderMaster" HorizontalContentAlignment="Center" BorderThickness="1" Margin="10" Grid.Row="3">
i worked around, and found listview is way more helpfull for my task,
Here's the markup:
<ListView Name="lvDataBinding" HorizontalContentAlignment="Stretch" BorderThickness="0" Margin="10" Grid.Row="3" Background="{x:Null}">
<ListView.ItemTemplate>
<DataTemplate>
<Border BorderBrush="Black" BorderThickness="0" CornerRadius="3" Margin="0,3" Grid.ColumnSpan="4" Background="White">
<Grid Background="White" Margin="0,1">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition Width="1.5*"/>
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="60"/>
</Grid.RowDefinitions>
<StackPanel Orientation="Vertical" Margin="50,5" >
<TextBlock Text="Customer" Foreground="#33B6EF" FontSize="20" />
<TextBlock Text="{Binding cust}" FontSize="20" />
</StackPanel>
<StackPanel Orientation="Vertical" Grid.Column="1">
<TextBlock Text="Location" Foreground="#33B6EF" FontSize="20" />
<TextBlock Text="{Binding loc}" FontSize="20" />
</StackPanel>
<StackPanel Orientation="Vertical" Grid.Column="2">
<TextBlock Text="Created On" Foreground="#33B6EF" FontSize="20" />
<TextBlock Text="{Binding con}" FontSize="20" />
</StackPanel>
<StackPanel Orientation="Vertical" Grid.Column="3">
<TextBlock Text="Quantity" Foreground="#33B6EF" FontSize="20" />
<TextBlock Text="{Binding quant}" FontSize="20" />
</StackPanel>
</Grid>
<Border.Effect>
<DropShadowEffect BlurRadius="5" ShadowDepth="5" />
</Border.Effect>
</Border>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>

expander collapse automatically when using Virtualization in list box

I have a Listbox control and I have an expander control in all the items so that user can expand each of the item. But when I expand few items and scroll it. some times the expander get collapse automatically.
<ListBox x:Name="listbox" ItemsSource="{Binding Persons}" Background="LightBlue"
ItemTemplate="{StaticResource PersonDataTemplate}"
ItemContainerStyle="{StaticResource ListBoxItemStyle}"
VirtualizingPanel.IsVirtualizing="True"
VirtualizingPanel.IsVirtualizingWhenGrouping="True"
HorizontalContentAlignment="Stretch">
<ListBox.GroupStyle>
<GroupStyle HeaderTemplate="{StaticResource GroupHeaderTemplate}" />
</ListBox.GroupStyle>
</ListBox>
and resources have
<DataTemplate x:Key="PersonDataTemplate" DataType="{x:Type local:Person}">
<Grid>
<Expander >
<Expander.Header>
<TextBlock Text="{Binding Name}"/>
</Expander.Header>
<!--This will take time to be instancied-->
<!--<local:TimeConsumingControl />-->
<!--Rest of the data template-->
<Border Margin="4" BorderBrush="Black" BorderThickness="1" MinHeight="40" CornerRadius="3" Padding="3">
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<!--<RowDefinition />-->
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<TextBlock Text="Name : " Grid.Row="0" FontWeight="Bold" HorizontalAlignment="Right" />
<TextBlock Grid.Column="1" Grid.Row="0" Text="{Binding Name}" />
<TextBlock Text=" - Age : " Grid.Column="2" Grid.Row="0" FontWeight="Bold"
HorizontalAlignment="Right" />
<TextBlock Grid.Column="3" Grid.Row="0" Text="{Binding Age}" />
</Grid>
</Border>
</Expander>
</Grid>
</DataTemplate>
How can I prevent the items from collapsing. I still want to use Virtualization.

Get selected item on expanderView

I'm using a ExpanderView to display some data in my app. But I'm having some difficulty trying to find out how to get an ExpanderViewItem's data after it's been selected.
On a ListBox you can call SelectionChanged="yourFunction" in your xaml code.. but for the expanderview I have no idea how to do this?
This is my XAML code for the expander:
<!--Custom header template-->
<DataTemplate x:Key="CustomHeaderTemplate">
<TextBlock Text="" FontSize="28" />
</DataTemplate>
<!--Custom expander template-->
<DataTemplate x:Key="CustomExpanderTemplate">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Rectangle Width="400" Height="60" Fill="#FFF1F1F1" HorizontalAlignment="Stretch" StrokeThickness="0" Grid.Row="0" Grid.Column="0" />
<TextBlock Text="{Binding procedureName}" FontSize="30" Foreground="#FF00457C" FontWeight="Normal" Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" Margin="10,0,0,0" />
</Grid>
</DataTemplate>
<!--Custom expander items template-->
<DataTemplate x:Key="ExpanderViewItems" >
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="15" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Image Source="{Binding flagIcon}" Grid.Row="0" Grid.RowSpan="3" Grid.Column="0" />
<TextBlock FontSize="26" Text="{Binding N}" Foreground="Black" FontWeight="Normal" Grid.Row="0" Grid.Column="1"/>
<TextBlock FontSize="20" Text="{Binding RNG}" Foreground="Black" FontWeight="Normal" HorizontalAlignment="Right" Grid.Row="0" Grid.Column="2"/>
<TextBlock FontSize="26" Text="{Binding ValueAndUnit}" Foreground="Black" FontWeight="Medium" HorizontalAlignment="Right" Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2"/>
<TextBlock FontSize="18" Text="{Binding COM}" Foreground="Black" FontWeight="Normal" Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="2" TextWrapping="Wrap" />
<Line StrokeThickness="1" Stroke="#C4C6CC" Stretch="Fill" X1="0" X2="1" Y1="0" Y2="0" VerticalAlignment="Center" Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="3" />
</Grid>
</DataTemplate>
<!--Listbox Containing ExpanderViews-->
<ListBox Name="testsList" Grid.Row="3" Grid.Column="0" >
<ListBox.ItemTemplate>
<DataTemplate>
<!--ExpanderView-->
<toolkit:ExpanderView Header="{Binding}"
HeaderTemplate="{StaticResource CustomHeaderTemplate}"
Expander="{Binding}"
ExpanderTemplate="{StaticResource CustomExpanderTemplate}"
x:Name="expander"
FontSize="36"
Foreground="#FF00457C"
ItemsSource="{Binding testItems}"
ItemTemplate="{StaticResource ExpanderViewItems}" >
</toolkit:ExpanderView>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
I'd really appreciate any help in the right direction! This seems to be a question that is not easily answered around the web.
#Frederik I've implemented what you've done in the code above using the SelectionChanged event of the ListBox - it still works fine for me.
I've been banging my head against the wall for a bit, but finally managed to solve it. First of all for the ItemTemplate I've made sure that the template is placed in a ListBoxItem element as it follows:
<DataTemplate x:Key="ExpanderViewItems" >
<ListBoxItem DataContext="{Binding}" Tap="ListBoxItem_Tap_1">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="15" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Image Source="{Binding flagIcon}" Grid.Row="0" Grid.RowSpan="3" Grid.Column="0" />
<TextBlock FontSize="26" Text="{Binding N}" Foreground="Black" FontWeight="Normal" Grid.Row="0" Grid.Column="1"/>
<TextBlock FontSize="20" Text="{Binding RNG}" Foreground="Black" FontWeight="Normal" HorizontalAlignment="Right" Grid.Row="0" Grid.Column="2"/>
<TextBlock FontSize="26" Text="{Binding ValueAndUnit}" Foreground="Black" FontWeight="Medium" HorizontalAlignment="Right" Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2"/>
<TextBlock FontSize="18" Text="{Binding COM}" Foreground="Black" FontWeight="Normal" Grid.Row="2" Grid.Column="1" Grid.ColumnSpan="2" TextWrapping="Wrap" />
<Line StrokeThickness="1" Stroke="#C4C6CC" Stretch="Fill" X1="0" X2="1" Y1="0" Y2="0" VerticalAlignment="Center" Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="3" />
</Grid>
</ListBoxItem>
</DataTemplate>
Once this is in place, go in the code behind and in the Tap event declared for the ListBoxItem use something like this:
ListBoxItem item = sender as ListBoxItem;
ExpanderItemModel model = item.DataContext as ExpanderItemModel;
Of course, ExpanderItemModel will be whatever you're using for your expander items...
This worked fine for me
Hope this helps!
Good luck!
You can use the "tap" event on the listbox:
In your XAML file add a tap event listner:
<!--Listbox Containing ExpanderViews-->
<ListBox Name="testsList" Grid.Row="3" Grid.Column="0" Tap="testsList_Tap" >
<ListBox.ItemTemplate>
<DataTemplate>
<!--ExpanderView-->
<toolkit:ExpanderView Header="{Binding}"
...
In your code behind file, implement the tap handler:
private void testsList_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
someModel selectedItem = (someModel)this.testsList.SelectedItem;
// Do something with your seleted data
...
}
you can get the selected values by listbox selectionchanged or expanderview expanded events.
For listbox :
private void lstExams_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (e.AddedItems.Count > 0)
{
Model.ExamTitles data = (sender as ListBox).SelectedItem as Model.ExamTitles;
}
}
Here ExamTitles is a class which contains collections
For expanderview Expanded
private void ExpanderView_Expanded(object sender, RoutedEventArgs e)
{
ExpanderView expview = (sender as ExpanderView);
Model.ExamTitles data = expview.Header as Model.ExamTitles;
}
Hope this helps!

Categories

Resources