or
<
Window
x:Class
=
"DelayedBinding.MainWindow"
xmlns:telerik
=
"http://schemas.telerik.com/2008/xaml/presentation"
Title
=
"MainWindow"
Height
=
"350"
Width
=
"525"
>
<
Grid
>
<
Grid.RowDefinitions
>
<
RowDefinition
Height
=
"*"
/>
<
RowDefinition
Height
=
"Auto"
/>
</
Grid.RowDefinitions
>
<
telerik:RadGridView
Grid.Row
=
"0"
x:Name
=
"radGridView"
AutoGenerateColumns
=
"False"
ItemsSource
=
"{Binding Path=Items}"
IsFilteringAllowed
=
"False"
ShowGroupPanel
=
"False"
CanUserSortColumns
=
"False"
>
<
telerik:RadGridView.Columns
>
<
telerik:GridViewDataColumn
Header
=
"Name"
Width
=
"65"
DataMemberBinding
=
"{Binding Path=Name}"
/>
<
telerik:GridViewDataColumn
IsVisible
=
"{Binding Path=ShowNumber}"
Header
=
"Number"
Width
=
"65"
x:Name
=
"NumberColumn"
DataMemberBinding
=
"{Binding Path=Number}"
/>
<
telerik:GridViewDataColumn
Header
=
"Group"
Width
=
"65"
DataMemberBinding
=
"{Binding Path=Group}"
/>
</
telerik:RadGridView.Columns
>
</
telerik:RadGridView
>
<
StackPanel
Grid.Row
=
"1"
Orientation
=
"Horizontal"
>
<
Button
Click
=
"ConnectVM"
Content
=
"ConnectVM"
Margin
=
"5"
/>
<
CheckBox
IsChecked
=
"{Binding Path=ShowNumber}"
Content
=
"Show Number"
VerticalAlignment
=
"Center"
/>
</
StackPanel
>
</
Grid
>
</
Window
>
using
System.Collections.ObjectModel;
using
System.ComponentModel;
using
System.Windows;
namespace
DelayedBinding
{
public
class
Item
{
public
string
Name {
get
;
set
; }
public
int
Number {
get
;
set
; }
public
string
Group {
get
;
set
; }
}
public
partial
class
MainWindow : Window, INotifyPropertyChanged
{
public
event
PropertyChangedEventHandler PropertyChanged;
public
ObservableCollection<Item> Items {
get
;
private
set
; }
private
bool
_ShowNumber =
false
;
public
bool
ShowNumber
{
get
{
return
_ShowNumber; }
set
{
_ShowNumber = value;
if
(PropertyChanged !=
null
)
PropertyChanged(
this
,
new
PropertyChangedEventArgs(
"ShowNumber"
));
}
}
public
MainWindow()
{
Items =
new
ObservableCollection<Item>();
for
(
int
i = 0; i < 5; i++)
Items.Add(
new
Item() { Name =
"Object "
+ i, Number = i, Group = (i % 2 == 1 ?
"Odd"
:
"Even"
) });
InitializeComponent();
// If we connect the DataContext here, everything works fine!
DataContext =
this
;
}
private
void
ConnectVM(
object
sender, RoutedEventArgs e)
{
// If we wait to connect it here, the ShowNumber binding isn't established!
DataContext =
this
;
// This is the work-around, by re-establishing the binding, the grid again works correctly.
//NumberColumn.SetBinding(Telerik.Windows.Controls.GridViewColumn.IsVisibleProperty, "ShowNumber");
}
}
}
<
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);