### VB.NET Data Binding Example Source: https://github.com/telerik/xaml-docs/blob/master/controls/radsparkline/radsparkline_databinding.md Illustrates data binding setup using a list of custom objects in VB.NET, similar to the C# example. ```vbnet Partial Public Class MainPage Inherits UserControl Public Sub New() 'MainWindow in WPF InitializeComponent() Dim today As Date = Date.Today Dim data As New List(Of MyCost)() From {New MyCost() With {.Cost = 1, .UnitCost = 2, .MyDate = today}, New MyCost() With {.Cost = 2, .UnitCost = 4, .MyDate = today.AddDays(1)}, New MyCost() With {.Cost = 3, .UnitCost = 6, .MyDate = today.AddDays(2)}, New MyCost() With {.Cost = 4, .UnitCost = 4, .MyDate = today.AddDays(3)}, New MyCost() With {.Cost = 5, .UnitCost = 8, .MyDate = today.AddDays(4)}} Me.DataContext = data End Sub End Class Public Class MyCost Public Property Cost() As Double Public Property UnitCost() As Double Public Property MyDate() As Date End Class ``` -------------------------------- ### Initialize RadWebCam with Specific Device and Format Source: https://github.com/telerik/xaml-docs/blob/master/controls/radwebcam/features/start-camera-manually.md Manually initialize the camera by selecting a video device and its supported format, then start the webcam. This should be done after the control is loaded, for example, in its Loaded event. ```C# ReadOnlyCollection videoDevices = RadWebCam.GetVideoCaptureDevices(); ReadOnlyCollection videoFormats = RadWebCam.GetVideoFormats(videoDevices[0]); this.radWebCam.Initialize(videoDevices[0], videoFormats[0]); this.radWebCam.Start(); ``` -------------------------------- ### Start RadWebCam Programmatically Source: https://github.com/telerik/xaml-docs/blob/master/controls/radwebcam/features/start-camera-manually.md Call the Start method to initiate the camera after disabling auto-start or at a later point in time. ```C# this.radWebCam.Start(); ``` -------------------------------- ### Initialize RadWebCam Without Audio Source: https://github.com/telerik/xaml-docs/blob/master/controls/radwebcam/how-to/mute-recording-audio.md In the Loaded event handler, get camera and video format information. Call Initialize, passing null for the audioDevice parameter to disable audio recording, then start the camera. ```C# private void RadWebcam_Loaded(object sender, RoutedEventArgs e) { ReadOnlyCollection videoDevices = RadWebCam.GetVideoCaptureDevices(); ReadOnlyCollection videoFormats = RadWebCam.GetVideoFormats(videoDevices[0]); this.radWebCam.Initialize(videoDevices[0], videoFormats[0], null); this.radWebCam.Start(); } ``` -------------------------------- ### Get Resizing Service in VB.NET Source: https://github.com/telerik/xaml-docs/blob/master/controls/raddiagram/features/services.md Retrieve an instance of a service by specifying its interface type. This example gets the IResizingService. ```vbnet xDiagram.ServiceLocator.GetService(Of IResizingService)() ``` -------------------------------- ### Set up Data Context with Sample Data (C#) Source: https://github.com/telerik/xaml-docs/blob/master/controls/raddatabar/databinding.md Initialize a List of Item objects and create a Product instance to serve as the DataContext. This prepares the data for binding to the RadDataBar controls. ```C# var items = new List() { new Item{ Val = 9, Name = "nine", }, new Item{ Val = 10, Name = "ten", }, new Item{ Val = 11, Name = "eleven", }, new Item{ Val = 20, Name = "twenty", }, new Item{ Val = 22, Name = "twenty two", }, new Item{ Val = 90, Name = "ninety", }, new Item{ Val = -9, Name = "-nine", }, new Item{ Val = -10, Name = "-ten", }, new Item{ Val = -11, Name = "-eleven", }, new Item{ Val = -20, Name = "-twenty", }, new Item{ Val = -100, Name = "-hundred", }, }; this.DataContext = new Product() { Value1 = 20, Value2 = 30, Ints = new List() {5, 6, 7, 8, 9, }, Items = items }; ``` -------------------------------- ### Get Resizing Service in C# Source: https://github.com/telerik/xaml-docs/blob/master/controls/raddiagram/features/services.md Retrieve an instance of a service by specifying its interface type. This example gets the IResizingService. ```csharp xDiagram.ServiceLocator.GetService(); ``` -------------------------------- ### Set up Data Context with Sample Data (VB.NET) Source: https://github.com/telerik/xaml-docs/blob/master/controls/raddatabar/databinding.md Initialize a List of Item objects and create a Product instance in VB.NET for the DataContext. This populates the data that will be bound to the RadDataBar controls. ```VB.NET Dim items = New List(Of Item)() From { New Item With {.Val = 9, .Name = "nine"}, New Item With {.Val = 10, .Name = "ten"}, New Item With {.Val = 11, .Name = "eleven"}, New Item With {.Val = 20, .Name = "twenty"}, New Item With {.Val = 22, .Name = "twenty two"}, New Item With {.Val = 90, .Name = "ninety"}, New Item With {.Val = -9, .Name = "-nine"}, New Item With {.Val = -10, .Name = "-ten"}, New Item With {.Val = -11, .Name = "-eleven"}, New Item With {.Val = -20, .Name = "-twenty"}, New Item With {.Val = -100, .Name = "-hundred"}} Dim TempProduct As Product = New Product() With {.Value1 = 20, .Value2 = 30, .Ints = New List(Of Integer)() From {5, 6, 7, 8, 9}, .Items = items} Me.DataContext = New Product() With {.Value1 = 20, .Value2 = 30, .Ints = New List(Of Integer)() From {5, 6, 7, 8, 9}, .Items ``` -------------------------------- ### Setting up the ViewModel with DataSet Source: https://github.com/telerik/xaml-docs/blob/master/controls/radgridview/populating-with-data/binding-to-dataset.md This code demonstrates how to create a ViewModel that returns a DataSet. Ensure a DataRelation is present for hierarchy generation. ```vbnet Imports System.Data Public Class MainViewModel Public Property DataSet As DataSet Public Sub New() Dim ds As New DataSet() ' ... populate DataSet ... Me.DataSet = ds End Sub End Class ``` -------------------------------- ### Define Appointment Filter Predicate in C# Source: https://github.com/telerik/xaml-docs/blob/master/controls/radscheduleview/features/filtering.md Implement the AppointmentFilter property to filter appointments based on their start date. This example filters for appointments starting today. ```C# public Predicate AppointmentsFilter { get { return Filter; } } public bool Filter(IAppointment appointment) { var app = appointment as Appointment; return app != null && TodaysAppointments(app); } public bool TodaysAppointments(Appointment app) { return app != null && app.Start.Date == DateTime.Today; } ``` -------------------------------- ### Sample Item Class and MainWindow Initialization (C#) Source: https://github.com/telerik/xaml-docs/blob/master/controls/radpanelbar/howto/object-data.md Defines a SampleItem class with Text and Items properties, and initializes the MainWindow by creating an ObservableCollection of SampleItem objects and setting it as the DataContext. This sets up the data source for the RadPanelBar. ```C# public class SampleItem : ViewModelBase { private string text; private ObservableCollection items; public string Text { get { return this.text; } set { if (this.text != value) { this.text = value; this.OnPropertyChanged("Text"); } } } public ObservableCollection Items { get { return this.items; } set { if (this.items != value) { this.items = value; this.OnPropertyChanged("Items"); } } } } public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); var source = new ObservableCollection(); for (int i = 1; i <= 3; i++) { var secondLevelItems = new ObservableCollection() { new SampleItem() { Text = "Second level " + i } }; source.Add(new SampleItem() { Text = "First level " + i, Items = secondLevelItems }); } this.DataContext = source; } } ``` -------------------------------- ### Showing RadVirtualKeyboardWindow Source: https://github.com/telerik/xaml-docs/blob/master/controls/radvirtualkeyboard/window.md Instantiate RadVirtualKeyboardWindow with a RadVirtualKeyboard instance and call the Show() method to display it. ```C# var keyboardWindow = new RadVirtualKeyboardWindow(new RadVirtualKeyboard()); keyboardWindow.Show(); ``` -------------------------------- ### Sample RadRibbonView Source: https://github.com/telerik/xaml-docs/blob/master/controls/radribbonview/how-to/howto-style-title.md A basic RadRibbonView setup to serve as a starting point for customization. ```XAML ``` -------------------------------- ### Example: Get Spans in Hyperlink Annotation (C#) Source: https://github.com/telerik/xaml-docs/blob/master/knowledge-base/kb-richtextbox-get-elements-in-annotation-range.md This example demonstrates how to use the GetElementsInAnnotationRange method to specifically retrieve all Span elements within a hyperlink annotation range. ```C# var spansInHyperlink = GetElementsInAnnotationRange(hyperlinkAnnotationStart, hyperlinkAnnotationStart.End); ``` -------------------------------- ### Prepare Sample Data (C#) Source: https://github.com/telerik/xaml-docs/blob/master/controls/radpropertygrid/features/unbound-mode.md Initializes an Employee object with nested Department data for use with RadPropertyGrid. ```csharp InitializeComponent(); this.rpg.Item = new Employee() { Name = "Nancy Davolio", HireDate = DateTime.Now, Department = new Department() { ID = 1, Name = "US Department" } }; ``` -------------------------------- ### RadTimeline Annotations ViewModel Example Source: https://github.com/telerik/xaml-docs/blob/master/controls/radtimeline/features/annotations.md A C# ViewModel class demonstrating the initialization of data for a RadTimeline, including setting the PeriodStart. This is a partial example and would typically be part of a larger data context setup. ```C# public class RadTimelineAnnotationsViewModel { public RadTimelineAnnotationsViewModel() { this.PeriodStart = new DateTime(2011, 1, 1); ``` -------------------------------- ### Set Recording File Path and Start Recording in Code Source: https://github.com/telerik/xaml-docs/blob/master/controls/radwebcam/features/recording-video.md Configure the video recording path and initiate recording programmatically. The file will be created if it doesn't exist, or overwritten if it does. ```C# string videoFileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "video.mp4"); // If there is no "video.mp4" file, such file will get created. If the file exists, it will get overridden. radWebCam.RecordingFilePath = videoFileName radWebCam.StartRecording(); ``` -------------------------------- ### Linear Scale Placement Example Source: https://github.com/telerik/xaml-docs/blob/master/controls/radgauge/features/linear-and-radial-scales/scales-linear-scale.md Positions a horizontal linear scale within its container using RelativeX and RelativeY properties. This example sets the scale to start at the top-left corner (0,0) and fill the container. ```XAML ``` -------------------------------- ### Sample Model and ViewModel in C# Source: https://github.com/telerik/xaml-docs/blob/master/knowledge-base/kb-gridview-style-aggregate-results-in-group-header.md Defines a Product class and a ViewModel to hold a collection of products. This setup is used for demonstrating conditional styling of aggregate results. ```C# public class Product { public Product(string name, int id) { this.Name = name; this.ID = id; } public string Name { get; set; } public int ID { get; set; } public static ObservableCollection GetProducts() { ObservableCollection products = new ObservableCollection(); var id = 0; for (int i = 1; i < 7; i++) { products.Add(new Product("Socks", ++id)); } products.Add(new Product("T-shirts", ++id)); products.Add(new Product("Shoes", ++id)); products.Add(new Product("Hats", ++id)); return products; } } public class ViewModel { private ObservableCollection products; public ObservableCollection Products { get { if(this.products == null) { this.products = Product.GetProducts(); } return this.products; } } } ``` -------------------------------- ### Prepare Sample Data (VB.NET) Source: https://github.com/telerik/xaml-docs/blob/master/controls/radpropertygrid/features/unbound-mode.md Initializes an Employee object with nested Department data for use with RadPropertyGrid. ```vbnet Public Sub New() InitializeComponent() Me.rpg.Item = New Employee() With { .Name = "Nancy Davolio", .HireDate = Date.Now, .Department = New Department() With { .ID = 1, .Name = "US Department" } } End Sub ``` -------------------------------- ### Get Cell Under Mouse - C# Source: https://github.com/telerik/xaml-docs/blob/master/controls/radspreadsheet/howto/get-cell-from-point.md This example demonstrates how to get the cell index under the mouse cursor during a `MouseMove` event. It requires accessing the `NormalWorksheetEditorPresenter` and using its `GetCellIndexFromViewPoint` method. The cell's value is then updated. ```C# private void MainWindow_Loaded(object sender, RoutedEventArgs e) { var worksheetEditor = this.radSpreadsheet.ActiveWorksheetEditor; if (worksheetEditor != null) { var presenter = worksheetEditor.ActivePresenter as NormalWorksheetEditorPresenter; presenter.PreviewMouseMove += Presenter_PreviewMouseMove; } } private void Presenter_PreviewMouseMove(object sender, MouseEventArgs e) { var presenter = sender as NormalWorksheetEditorPresenter; Point position = e.GetPosition(presenter); CellIndex clickedCellIndex = presenter.GetCellIndexFromViewPoint(position); string clickValue = String.Format("Hovered!"); this.radSpreadsheet.ActiveWorksheet.Cells[clickedCellIndex].SetValue(clickValue); } ``` -------------------------------- ### Set Custom DataTemplate for RadDiagramConnection Source: https://github.com/telerik/xaml-docs/blob/master/controls/raddiagram/getting-started.md Customizes the appearance and content of a RadDiagramConnection, including its start and target cap types, and content template. This example shows how to display 'Start' text with specific alignment and margins. ```XAML ``` -------------------------------- ### Run Bootstrapper in App.xaml.cs (C#) Source: https://github.com/telerik/xaml-docs/blob/master/controls/radoutlookbar/how-to/how_to_use_radoutlookbar_as_a_container_in_prism_application.md Modify the Application_Startup event handler in App.xaml.cs to instantiate and run the bootstrapper. This is the entry point for initializing the Prism application. ```C# private void Application_Startup(object sender, StartupEventArgs e) { Bootstrapper bootstrapper = new Bootstrapper(); bootstrapper.Run(); } ``` -------------------------------- ### Define RadFilePathPicker in XAML Source: https://github.com/telerik/xaml-docs/blob/master/controls/radfilepathpicker/getting-started.md This is the basic definition of the RadFilePathPicker control in XAML. No additional setup is required to start using it. ```XAML ``` -------------------------------- ### Create Line Chart Series with Manual Mappings Source: https://github.com/telerik/xaml-docs/blob/master/controls/radchart/how-to/howto-highlight-pointmark-on-click.md Demonstrates how to create a Line Series using manual data mappings and populate it with sample data. This setup is required before handling item click events. ```C# public MainPage() //MainWindow() for WPF { InitializeComponent(); Random r = new Random(); List chartData = new List(); for (int i = 0; i < 20; i++) { chartData.Add(new ItemData(i, r.Next(0, 100))); } this.radChart.ItemsSource = chartData; this.SetUpMappings(); } private void SetUpMappings() { SeriesMapping mapping = new SeriesMapping(); mapping.SeriesDefinition = new LineSeriesDefinition() { ShowItemToolTips = true, ShowItemLabels = false }; mapping.ItemMappings.Add(new ItemMapping("YValue", DataPointMember.YValue)); mapping.ItemMappings.Add(new ItemMapping("XValue", DataPointMember.XValue)); this.radChart.SeriesMappings.Add(mapping); } public class ItemData { public double XValue { get; set; } public double YValue { get; set; } public ItemData(double xValue, double yValue) { this.XValue = xValue; this.YValue = yValue; } } ``` ```VB.NET Public Sub New() 'MainWindow() for WPF InitializeComponent() Dim r As New Random() Dim chartData As New List(Of ItemData)() For i As Integer = 0 To 19 chartData.Add(New ItemData(i, r.Next(0, 100))) Next i Me.radChart.ItemsSource = chartData Me.SetUpMappings() End Sub Private Sub SetUpMappings() Dim mapping As New SeriesMapping() mapping.SeriesDefinition = New LineSeriesDefinition() With {.ShowItemToolTips = True, .ShowItemLabels = False} mapping.ItemMappings.Add(New ItemMapping("YValue", DataPointMember.YValue)) mapping.ItemMappings.Add(New ItemMapping("XValue", DataPointMember.XValue)) Me.radChart.SeriesMappings.Add(mapping) End Sub Public Class ItemData Public Property XValue() As Double Public Property YValue() As Double Public Sub New(ByVal xValue As Double, ByVal yValue As Double) Me.XValue = xValue Me.YValue = yValue End Sub End Class ``` -------------------------------- ### Complete RadLayoutControl Example with Nested Groups Source: https://github.com/telerik/xaml-docs/blob/master/controls/radlayoutcontrol/getting-started/getting-started.md Demonstrates a comprehensive setup of RadLayoutControl featuring nested layout groups, expander groups, tab groups, and various child elements. This example showcases how to structure complex UIs with RadLayoutControl. ```XAML