or

<Window x:Class="CollapsedAxis.MainWindow" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" Title="MainWindow" Height="400" Width="600"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="*"/> <RowDefinition Height="*"/> <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <telerik:RadCartesianChart x:Name="PropertyChart1" Grid.Row="0"> <telerik:RadCartesianChart.HorizontalAxis> <telerik:DateTimeCategoricalAxis Visibility="Collapsed"/> </telerik:RadCartesianChart.HorizontalAxis> <telerik:RadCartesianChart.VerticalAxis> <telerik:LinearAxis Visibility="Collapsed"/> </telerik:RadCartesianChart.VerticalAxis> <telerik:RadCartesianChart.Series> <telerik:LineSeries CategoryBinding="Date" ValueBinding="Value" ItemsSource="{Binding Path=Series1}"> </telerik:LineSeries> </telerik:RadCartesianChart.Series> </telerik:RadCartesianChart> <telerik:RadCartesianChart x:Name="PropertyChart2" Grid.Row="1"> <telerik:RadCartesianChart.HorizontalAxis> <telerik:DateTimeCategoricalAxis Visibility="{Binding Path=AxisVisible}"/> </telerik:RadCartesianChart.HorizontalAxis> <telerik:RadCartesianChart.VerticalAxis> <telerik:LinearAxis Visibility="{Binding Path=AxisVisible}"/> </telerik:RadCartesianChart.VerticalAxis> <telerik:RadCartesianChart.Series> <telerik:LineSeries CategoryBinding="Date" ValueBinding="Value" ItemsSource="{Binding Path=Series1}"> </telerik:LineSeries> </telerik:RadCartesianChart.Series> </telerik:RadCartesianChart> <CheckBox Grid.Row="2" IsChecked="{Binding Path=DisplayAxis}" Content="Display Axis" HorizontalAlignment="Left"/> </Grid></Window>
using System;using System.Collections.Generic;using System.ComponentModel;using System.Windows;using System.Windows.Data;using Telerik.Windows.Controls.ChartView;namespace CollapsedAxis{ public class MyPoint { public DateTime Date { get; set; } public Double Value { get; set; } } public partial class MainWindow : Window, INotifyPropertyChanged { public List<MyPoint> Series1 { get; private set; } private bool _DisplayAxis; public bool DisplayAxis { get { return _DisplayAxis; } set { _DisplayAxis = value; AxisVisible = (_DisplayAxis ? Visibility.Visible : Visibility.Collapsed); RaisePropertyChanged("DisplayAxis"); } } private Visibility _AxisVisible; public Visibility AxisVisible { get { return _AxisVisible; } set { _AxisVisible = value; // Enabling this to replace the axis instead of just using the binding to // collapse it results in the correct behavior. //PropertyChart2.HorizontalAxis = new DateTimeCategoricalAxis() { Visibility = _AxisVisible }; RaisePropertyChanged("AxisVisible"); } } public MainWindow() { Series1 = new List<MyPoint>(); _DisplayAxis = false; _AxisVisible = Visibility.Collapsed; for (int i = 0; i < 5; i++) { DateTime date = DateTime.Today.AddDays(i); Series1.Add(new MyPoint() { Date = date, Value = i * 1000 }); } InitializeComponent(); DataContext = this; } #region INotifyPropertyChanged public event PropertyChangedEventHandler PropertyChanged; protected void RaisePropertyChanged(string propertyName) { if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } #endregion }}
if (((System.Windows.Controls.Canvas)this.Parent).Parent is Window) { Window thisWindow = ((System.Windows.Controls.Canvas)this.Parent).Parent as Window; thisWindow.ShowInTaskbar = true; thisWindow.Title = this.Header.ToString(); this.Icon = thisWindow.Icon; } Uri iconUri = new Uri("pack://application:,,,/WPFIcon2.ico", UriKind.RelativeOrAbsolute); this.Icon = BitmapFrame.Create(iconUri);
