or
| <Style x:Key="RadCarouselStyle1" TargetType="{x:Type telerik:RadCarousel}"> |
| <Style.BasedOn> |
| <Style TargetType="{x:Type telerik:RadCarousel}"> |
| <Setter Property="Template"> |
| <Setter.Value> |
| <ControlTemplate TargetType="{x:Type telerik:RadCarousel}"> |
| <Grid> |
| <Grid.ColumnDefinitions> |
| <ColumnDefinition Width="50*" /> |
| <ColumnDefinition Width="50*" /> |
| </Grid.ColumnDefinitions> |
| <Button x:Name="EnSolItem" HorizontalAlignment="Right" VerticalAlignment="Bottom" Grid.Column="0" Width="40" Height="40" Margin="0,0,40,0" Content="EnSol" /> |
| <Button x:Name="SolItem" HorizontalAlignment="Right" VerticalAlignment="Bottom" Grid.Column="0" Width="40" Height="40" Content="Sol" /> |
| <Button x:Name="SagItem" HorizontalAlignment="Left" VerticalAlignment="Bottom" Grid.Column="1" Width="40" Height="40" Content="SaÄŸ" /> |
| <Button x:Name="EnSagItem" HorizontalAlignment="Left" VerticalAlignment="Bottom" Grid.Column="1" Width="40" Height="40" Margin="40,0,0,0" Content="EnSaÄŸ" /> |
| <Border Grid.ColumnSpan="2" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" |
| BorderThickness="{TemplateBinding BorderThickness}"> |
| <telerik:CarouselItemsControl x:Name="PART_RootItemsControl" Grid.ColumnSpan="2"/> |
| </Border> |
| </Grid> |
| </ControlTemplate> |
| </Setter.Value> |
| </Setter> |
| <Setter Property="ClipToBounds" Value="True"/> |
| </Style> |
| </Style.BasedOn> |
| </Style> |
this is the template i'm using,
<telerik:RadCarousel x:Name="radCarousel" Style="{DynamicResource RadCarouselStyle1}"/>
In my code Behind, I have an event handler and a function to give the path and etc.
| void radCarousel_Loaded(object sender, RoutedEventArgs e) |
| { |
| Telerik.Windows.Controls.RadCarouselPanel panel = this.radCarousel.FindCarouselPanel(); |
| this.radCarousel.ReflectionSettings.Visibility = Visibility.Visible; |
| this.radCarousel.ReflectionSettings.OffsetX = 0; |
| this.radCarousel.ReflectionSettings.OffsetY = 5; |
| this.radCarousel.ReflectionSettings.HiddenPercentage = 0; |
| this.radCarousel.ReflectionSettings.Opacity = 0.5; |
| this.radCarousel.ReflectionSettings.HeightOffset = 0; |
| this.radCarousel.ReflectionSettings.WidthOffset = 0; |
| this.radCarousel.ReflectionSettings.Angle = 0; |
| System.Windows.Shapes.Path path = CreateLinePath(); |
| if (panel != null) |
| { |
| this.radCarousel.FindCarouselPanel().Path = path; |
| this.radCarousel.FindCarouselPanel().ItemsPerPage = 7; |
| } |
| } |
| private System.Windows.Shapes.Path CreateLinePath() |
| { |
| System.Windows.Shapes.Path newPath = new System.Windows.Shapes.Path(); |
| PathFigureCollectionConverter figureConverter = new PathFigureCollectionConverter(); |
| object geometryFigures = figureConverter.ConvertFromString("M30,200 L307.5,200"); |
| PathGeometry newGeometry = new PathGeometry(); |
| newPath.Stretch = Stretch.Fill; |
| BrushConverter brushConverter = new BrushConverter(); |
| newPath.Stroke = (System.Windows.Media.Brush)brushConverter.ConvertFromString("#FF0998f8"); |
| newPath.StrokeThickness = 2; |
| newGeometry.Figures = (PathFigureCollection)geometryFigures; |
| newPath.Data = (Geometry)newGeometry; |
| return newPath; |
| } |
While i'm setting the
this.radCarousel.FindCarouselPanel().Path = path;
this.radCarousel.FindCarouselPanel().ItemsPerPage = 7;
part, FindCarouselPanel() returns null. Yesterday it was working. I didn't changed anything except the Style of radCarousel. Should i be implementing the RadCarouselPanel to style as well?
Please help.
| // Binding to be set for control |
| Binding binding = new Binding("Value"); |
| binding.Mode = BindingMode.TwoWay; |
| binding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged; |
| string datePickerXamlTemplate = "<telerik:RadDatePicker x:Name=\"uxDatePickerCustomField{0}\" Grid.Row=\"1\" Grid.Column=\"1\" Height=\"24\" HorizontalAlignment=\"Left\" Margin=\"8,5,8,5\" Width=\"125\" xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\" xmlns:telerik=\"clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Input\" xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\" />"; |
| string datePickerXaml = string.Format(datePickerXamlTemplate, field.Id, count); |
| stream = new MemoryStream(ASCIIEncoding.Default.GetBytes(datePickerXaml)); |
| RadDatePicker datePicker = (RadDatePicker)System.Windows.Markup.XamlReader.Load(stream); |
| datePicker.SetBinding(RadDatePicker.SelectedDateProperty, binding); |
| datePicker.Style = (Style)FindResource("DatePickerStyle"); |
| datePicker.DataContext = field; // Object having properties - Value and IsValidFieldValue. Implements INotifyPropertyChanged |
| uxGrid.Children.Add(datePicker); // Added to a Grid |
| <UserControl.Resources> |
| <Style TargetType="{x:Type telerikInput:RadDatePicker}" x:Key="DatePickerStyle"> |
| <Style.Triggers> |
| <DataTrigger Binding="{Binding Path=IsValidFieldValue, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" Value="false"> |
| <Setter Property="telerikInput:RadDatePicker.Background" Value="#FFFFB9B9" /> |
| </DataTrigger> |
| </Style.Triggers> |
| </Style> |
| </UserControl.Resources> |
| public class DummyObject |
| { |
| public DummyObject(string name, string notes) |
| { |
| Name = name; |
| Notes = notes; |
| } |
| public string Name |
| { |
| get; |
| set; |
| } |
| public string Notes |
| { |
| get; |
| set; |
| } |
| } |
| public partial class Window1 : Window |
| { |
| public Window1() |
| { |
| InitializeComponent(); |
| //This works fine |
| //PopulateGrid(); |
| } |
| private void Populate_Click(object sender, RoutedEventArgs e) |
| { |
| //This will throw an exception |
| PopulateGrid(); |
| } |
| private void PopulateGrid() |
| { |
| List<DummyObject> myObjects = new List<DummyObject>() |
| { |
| new DummyObject("Justin", "Here is a note"), |
| new DummyObject("Paul", "Paul has a note too"), |
| new DummyObject("Sam", "Sam has a note that is much longer than the other notes"), |
| new DummyObject("Dean", "Nothing to see here"), |
| new DummyObject("Andrew", "Blah blah blah blah") |
| }; |
| mainGrid.DataContext = myObjects; |
| } |
| } |
| <Window x:Class="TeleirkDatagridBug.Window1" |
| 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" |
| Title="Window1" Height="300" Width="300"> |
| <DockPanel> |
| <StackPanel DockPanel.Dock="Top"> |
| <Button Content="Populate" Click="Populate_Click"/> |
| </StackPanel> |
| <telerik:RadGridView AutoGenerateColumns="False" x:Name="mainGrid" ItemsSource="{Binding}"> |
| <telerik:RadGridView.Columns> |
| <telerik:GridViewDataColumn Width="100" HeaderText="Name" UniqueName="Name"/> |
| <telerik:GridViewDataColumn Width="*" HeaderText="Notes" UniqueName="Notes"/> |
| </telerik:RadGridView.Columns> |
| </telerik:RadGridView> |
| </DockPanel> |
| </Window> |