I put a RadComboBox in RadGridView and set the RadGridView's height a small value. Run the application, RadGridView will display the VerticalScrollBar automatically. I found that after scroll the VerticalScrollBar up or down serveral times, the RadComBox's items dispeared. Is it a bug?
------------------------------------------------------------------
MainPage.xaml :
-----------------------------------------------------------
MainPage.xaml.cs:
-----------------------------------------------
Company.cs
--------------------------------------------------------
Employee.cs
------------------------------------------------------------------
TextValueObject.cs
-------------------------------------------
SexCollection.cs
------------------------------------------------------------------
MainPage.xaml :
<
UserControl
x:Class
=
"RadControlsBug.MainPage"
xmlns:telerik
=
"http://schemas.telerik.com/2008/xaml/presentation"
mc:Ignorable
=
"d"
d:DesignWidth
=
"640"
d:DesignHeight
=
"480"
>
<
Grid
x:Name
=
"LayoutRoot"
>
<
telerik:RadGridView
ItemsSource
=
"{Binding Employees,Mode=TwoWay}"
ShowGroupPanel
=
"False"
RowIndicatorVisibility
=
"Collapsed"
CanUserFreezeColumns
=
"False"
Margin
=
"10"
AutoGenerateColumns
=
"False"
Height
=
"90"
Width
=
"300"
>
<
telerik:RadGridView.Columns
>
<
telerik:GridViewColumn
Header
=
"Name"
>
<
telerik:GridViewColumn.CellTemplate
>
<
DataTemplate
>
<
telerik:RadMaskedTextInput
Width
=
"100"
Value
=
"{Binding Name,Mode=TwoWay}"
TextMode
=
"PlainText"
Margin
=
"5"
></
telerik:RadMaskedTextInput
>
</
DataTemplate
>
</
telerik:GridViewColumn.CellTemplate
>
</
telerik:GridViewColumn
>
<
telerik:GridViewColumn
Header
=
"Sex"
>
<
telerik:GridViewColumn.CellTemplate
>
<
DataTemplate
>
<
telerik:RadComboBox
ItemsSource
=
"{Binding SexList,Mode=TwoWay}"
SelectedValue
=
"{Binding Sex,Mode=TwoWay}"
SelectedValuePath
=
"Value"
DisplayMemberPath
=
"Text"
Margin
=
"5"
>
</
telerik:RadComboBox
>
</
DataTemplate
>
</
telerik:GridViewColumn.CellTemplate
>
</
telerik:GridViewColumn
>
</
telerik:RadGridView.Columns
>
</
telerik:RadGridView
>
</
Grid
>
</
UserControl
>
MainPage.xaml.cs:
using
System.Windows;
using
System.Windows.Controls;
using
RadControlsBug.Model;
namespace
RadControlsBug
{
public
partial
class
MainPage : UserControl
{
private
Company _viewModel =
new
Company();
public
MainPage()
{
InitializeComponent();
this
.Loaded +=
new
RoutedEventHandler(MainPage_Loaded);
}
void
MainPage_Loaded(
object
sender, RoutedEventArgs e)
{
_viewModel.Employees.Add(
new
Employee() { Name =
"Jimmy"
, Sex =
"M"
});
_viewModel.Employees.Add(
new
Employee() { Name =
"Mike"
, Sex =
"M"
});
_viewModel.Employees.Add(
new
Employee() { Name =
"Jack"
, Sex =
"M"
});
_viewModel.Employees.Add(
new
Employee() { Name =
"Rose"
, Sex =
"F"
});
_viewModel.Employees.Add(
new
Employee() { Name =
"Kate"
, Sex =
"F"
});
this
.DataContext = _viewModel;
}
}
}
Company.cs
using
System.Collections.ObjectModel;
namespace
RadControlsBug.Model
{
public
class
Company
{
public
string
CompanyName {
set
;
get
; }
private
ObservableCollection<Employee> _employees =
new
ObservableCollection<Employee>();
public
ObservableCollection<Employee> Employees
{
get
{
return
_employees; }
set
{ _employees = value; }
}
}
}
Employee.cs
using
System.Collections.Generic;
namespace
RadControlsBug.Model
{
public
class
Employee
{
public
string
Name {
set
;
get
; }
public
string
Sex {
set
;
get
; }
public
List<TextValueObject> SexList {
get
{
return
SexCollection.SexList; }
}
}
}
TextValueObject.cs
namespace
RadControlsBug.Model
{
public
class
TextValueObject
{
public
string
Text {
set
;
get
; }
public
string
Value {
set
;
get
; }
}
}
SexCollection.cs
using
System.Collections.Generic;
namespace
RadControlsBug.Model
{
public
static
class
SexCollection
{
private
static
List<TextValueObject> _SexList =
new
List<TextValueObject>();
public
static
List<TextValueObject> SexList
{
get
{
return
SexCollection._SexList; }
}
static
SexCollection()
{
_SexList.Add(
new
TextValueObject() { Text =
"Male"
, Value =
"M"
});
_SexList.Add(
new
TextValueObject() { Text =
"Female"
, Value =
"F"
});
}
}
}