This question is locked. New answers and comments are not allowed.
Hi
please try this,
c#
if you run it, u get null reference exception. the reason i guess is, when the first TileViewItem is created, it is trying to bind to TileState which is set to Max. This will trigger this first tile to maximize itself and also it will try to minimize second tile which have not been created yet.
Regards,
Alex
please try this,
<
UserControl
x:Class
=
"TestSilverlightApplication.MainPage1"
xmlns:telerik
=
"clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation"
xmlns:Controls
=
"clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls"
xmlns:TestSilverlightApplication
=
"clr-namespace:TestSilverlightApplication"
mc:Ignorable
=
"d"
d:DesignHeight
=
"435"
d:DesignWidth
=
"613"
>
<
UserControl.Resources
>
<
TestSilverlightApplication:MainViewModel
x:Key
=
"MainViewModel"
/>
<
Controls:ContainerBindingCollection
x:Key
=
"ContainerBindingCollection"
>
<
Controls:ContainerBinding
PropertyName
=
"TileState"
Binding
=
"{Binding TileState, Mode=TwoWay}"
/>
</
Controls:ContainerBindingCollection
>
<
DataTemplate
x:Key
=
"ItemTemplate"
Controls:ContainerBinding.ContainerBindings
=
"{StaticResource ContainerBindingCollection}"
>
<
TextBlock
Text
=
"{Binding Path=Header}"
/>
</
DataTemplate
>
</
UserControl.Resources
>
<
Grid
x:Name
=
"LayoutRoot"
Background
=
"White"
DataContext
=
"{StaticResource MainViewModel}"
>
<
telerik:RadTileView
ItemsSource
=
"{Binding Path=TileViewModels}"
ItemTemplate
=
"{StaticResource ItemTemplate}"
/>
</
Grid
>
</
UserControl
>
c#
using
System.Collections.Generic;
using
System.Windows.Controls;
namespace
TestSilverlightApplication
{
using
Telerik.Windows.Controls;
using
ViewModelBase = GalaSoft.MvvmLight.ViewModelBase;
public
partial
class
MainPage1 : UserControl
{
public
MainPage1()
{
InitializeComponent();
}
}
public
class
MainViewModel :ViewModelBase
{
public
MainViewModel()
{
TileViewModels =
new
List<TileViewModel>
{
new
TileViewModel() { Header =
"h1"
, SmallContent =
"small1"
, Content =
"normal1"
, LargeContent =
"large1"
, TileState = TileViewItemState.Maximized},
new
TileViewModel() { Header =
"h2"
, SmallContent =
"small2"
, Content =
"normal2"
, LargeContent =
"large2"
},
};
}
public
List<TileViewModel> TileViewModels {
get
;
set
; }
}
public
class
TileViewModel : ViewModelBase
{
public
string
Header {
get
;
set
; }
public
string
SmallContent {
get
;
set
; }
public
string
Content {
get
;
set
; }
public
string
LargeContent {
get
;
set
; }
public
TileViewItemState TileState {
get
;
set
; }
}
}
if you run it, u get null reference exception. the reason i guess is, when the first TileViewItem is created, it is trying to bind to TileState which is set to Max. This will trigger this first tile to maximize itself and also it will try to minimize second tile which have not been created yet.
Regards,
Alex