or
I found this article without answer. I have the same problem can anybody help me?
I am using Telerik's WPF controls. In particular the DataForm control. I am trying to bind it to an object that has the following make up.
public class FrequencyMap : BindableBase
{
private Guid id;
public Guid ID
{
get { return id; }
set
{
id = value;
OnPropertyChanged();
}
}
private string procedureCodeId;
public string ProcedureCodeId
{
get { return procedureCodeId; }
set
{
procedureCodeId = value;
OnPropertyChanged();
}
}
private FrequencyChoice frequency;
public FrequencyChoice Frequency
{
get { return frequency; }
set
{
frequency = value;
OnPropertyChanged();
}
}
private DateTime effectiveDate;
public DateTime EffectiveDate
{
get { return effectiveDate; }
set
{
effectiveDate = value;
OnPropertyChanged();
}
}
private DateTime? terminateDate;
public DateTime? TerminateDate
{
get { return terminateDate; }
set
{
terminateDate = value;
OnPropertyChanged();
}
}
}
and then the FrequencyChoice object looks like this:
public class FrequencyChoice : BindableBase
{
private int id;
private string modifiedUser;
public int ID
{
get { return id; }
set
{
id = value; OnPropertyChanged();
}
}
private string code;
public string Code
{
get { return code; }
set
{
code = value; OnPropertyChanged();
}
}
private string name;
public string Name
{
get { return name; }
set
{
name = value; OnPropertyChanged();
}
}
private string description;
public string Description
{
get { return description; }
set
{
description = value; OnPropertyChanged();
}
}
private string calculationDescription;
public string CalculationDescription
{
get { return calculationDescription; }
set
{
calculationDescription = value; OnPropertyChanged();
}
}
private DateTime inactiveDate;
public DateTime InactiveDate
{
get { return inactiveDate; }
set
{
inactiveDate = value; OnPropertyChanged();
}
}
public string ModifiedUser
{
get
{
return this.modifiedUser;
}
set
{
this.modifiedUser = value;
OnPropertyChanged();
}
}
}
This works quite well except for the Frequency property. How do I get that to work properly(I need name property to be in drop down list box for choose). Do I have to use an Enum like this article? Data Forms in your XAML If so how would I link the two?
Thank you for your help.
Ondrej
<telerik:RadGridView Grid.Row="1"HorizontalAlignment="Stretch"ItemsSource="{Binding Articles}"AutoGenerateColumns="False"ShowGroupPanel="False"RowIndicatorVisibility="Collapsed"CanUserDeleteRows="False"CanUserInsertRows="False"CanUserReorderColumns="False"
GridLinesVisibility="None"BorderBrush="{x:Null}"AllowDrop="{Binding CanReOrderRows}"IsReadOnly="True"IsFilteringAllowed="False"CanUserFreezeColumns="False"SelectionMode="{Binding GridViewSelectionMode}"SelectedItem="{Binding ArticleModel, Mode=TwoWay}"b:RowReorderBehavior.IsEnabled="{Binding CanReOrderRows, Mode=TwoWay}"telerik:ScrollingSettingsBehavior.IsEnabled="True"telerik:ScrollingSettingsBehavior.ScrollAreaPadding="30"telerik:ScrollingSettingsBehavior.ScrollStep="24"telerik:ScrollingSettingsBehavior.ScrollStepTime="00:00:00.05"> <i:Interaction.Behaviors> <b:ScrollIntoViewBehavior /> </i:Interaction.Behaviors> <telerik:RadGridView.Columns> <telerik:GridViewColumn IsVisible="{Binding IsGridViewDragDropColumnVisible}"> <telerik:GridViewColumn.CellTemplate> <DataTemplate> <StackPanel> <Image> <Image.Style> <Style TargetType="{x:Type Image}"> <Style.Triggers> <DataTrigger Binding="{Binding IsTotal}" Value="False"> <Setter Property="Source" Value="../Images/draggable-icon.gif" /> </DataTrigger> </Style.Triggers> </Style> </Image.Style> </Image> </StackPanel> </DataTemplate> </telerik:GridViewColumn.CellTemplate> </telerik:GridViewColumn> <telerik:GridViewSelectColumn IsVisible="{Binding IsGridViewCheckBoxColumnVisible}" /> <telerik:GridViewDataColumn DataMemberBinding="{Binding Article.Name}" Header="Article" IsSortable="False" Width="*" /> <telerik:GridViewDataColumn DataMemberBinding="{Binding Article.Price, Converter={StaticResource ZeroPriceConverter}}" Header="ArticlePrice" IsSortable="False" /> <telerik:GridViewDataColumn DataMemberBinding="{Binding Count}" Header="Count" IsSortable="False" /> <telerik:GridViewDataColumn DataMemberBinding="{Binding TotalPrice}" Header="Total" IsSortable="False" /> </telerik:RadGridView.Columns> </telerik:RadGridView>DataTable dt = new DataTable("test");for (int i = 0; i < 10; i++){ dt.Columns.Add("column" + i);}for (int i = 0; i < 10; i++){ var row = dt.NewRow(); for (int j = 0; j < 10; j++) { row[j] = j + i; } dt.Rows.Add(row);}dt.AcceptChanges();Items = dt.AsDataView();
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="253*" />
</Grid.RowDefinitions>
<Button Command="{Binding UndoAllChanges}" Content="Undo all changes" Margin="10" HorizontalAlignment="Left" Padding="5,2" />
<telerik:RadGridView ItemsSource="{Binding Items}" CanUserInsertRows="True" ShowInsertRow="True" Grid.Row="1" />
</Grid>
private ICommand _undoAllChanges;public ICommand UndoAllChanges{ get { if (_undoAllChanges == null) { _undoAllChanges = new DelegateCommand(obj => { Items.Table.RejectChanges(); OnPropertyChanged("Items"); }); } return _undoAllChanges; }}public class LstStyleSelector:StyleSelector
{
public Style Red { get; set; }
public Style Blue { get; set; }
public override Style SelectStyle(object item, DependencyObject container)
{
if (item != null)
{
if (((KeyValuePair<int, string>)item).Key % 2 == 0)
return Red;
else
return Blue;
}
else
return Red;
}
}<Grid>
<Grid.Resources>
<Style x:Key="reditem" TargetType="{x:Type telerik:RadListBoxItem}">
<Setter Property="Background" Value="Red"/>
</Style>
<Style x:Key="bluitem" TargetType="{x:Type telerik:RadListBoxItem}">
<Setter Property="Background" Value="Blue"/>
</Style>
<local:LstStyleSelector x:Key="itemContainerStyle" Blue="{StaticResource bluitem}" Red="{StaticResource reditem}"/>
</Grid.Resources>
<telerik:RadListBox x:Name="lstbx" VerticalAlignment="Center" DisplayMemberPath="Value" ItemContainerStyleSelector="{StaticResource itemContainerStyle}"/>
</Grid>private void Application_Startup(object sender, StartupEventArgs e)
{
//StyleManager.ApplicationTheme = new Windows8TouchTheme(); //StyleSelector not working.
StyleManager.ApplicationTheme = new Office_BlackTheme(); //StyleSelector working fine!
}gridView.ItemsSource = orgList;gridView.SelectedItem = orgList[0];//// gridView.rows[0].Expand(); // <-- Yes, I know this doesn't exist, but pretty please add it.gridView.ItemsSource = orgList;Action a = delegate { gridView.SelectedItem = orgList[0];};Thread.Sleep(100);App.Current.Dispatcher.Invoke(a, null);gridView.RowDetailsVisibilityMode = GridViewRowDetailsVisibilityMode.Visible;gridView.ItemsSource = orgList;Action a = delegate { gridView.SelectedItem = orgList[0]; gridView.UpdateLayout(); var row = gridView.ItemContainerGenerator.ContainerFromItem(gridView.SelectedItem) as GridViewRow; if (row != null) { row.DetailsVisibility = Visibility.Visible; row.IsExpanded = true; }};Thread.Sleep(100);App.Current.Dispatcher.Invoke(a, null);var row2 = row.ChildrenOfType<DetailsPresenter>().FirstOrDefault() as DetailsPresenter;if (row2 != null) { var details = row2.Content as RadGridView; if (details != null) { details.SelectedItem = obj2; details.ScrollIntoView(obj2); }}