or
private void BindDataMainGrid() |
{ |
try |
{ |
GridViewTableDefinition BudgetTableDefinition = new GridViewTableDefinition(); |
BudgetTableDefinition.Relation = new PropertyRelation("Budget"); |
GridViewTableDefinition SubBudgetTableDefinition = new GridViewTableDefinition(); |
SubBudgetTableDefinition.Relation = new PropertyRelation("SubBudget"); |
this.gvAccount.ItemsSource = this.GetData(); |
} |
catch{} |
} |
private void OnChildGridLoaded(object sender, RoutedEventArgs e) |
{ |
try |
{ |
var dataRowView = (DataRowView)((RadGridView)sender).ParentRow.DataContext; |
var ds = dataRowView.DataView.Table.DataSet; |
var childData = dataRowView.CreateChildView(ds.Relations["BudgetRelation"]); |
//סינון הערכים בגריד לפי סוג פעילות |
if (((ComboBoxValues.ComboValues)cmbActivityType.SelectedValue).Id != 0) |
{ |
childData.RowFilter = "ActivityTypeID=" + ((ComboBoxValues.ComboValues)cmbActivityType.SelectedValue).Id; |
((RadGridView)sender).ItemsSource = childData; |
} |
else |
{ |
((RadGridView)sender).ItemsSource = null; |
((RadGridView)sender).ItemsSource = childData; |
} |
//סינון הערכים בתיבת הבחירה בעמודה של סוג פעילות |
if (Convert.ToInt32(dataRowView.Row.ItemArray[5]) == 1) |
{ |
((GridViewComboBoxColumn)((RadGridView)sender).Columns["ActivityTypeID"]).ItemsSource = ComboBoxValues.GetComboValues(dtActivityType.Select("ID < 2000")); |
} |
if (Convert.ToInt32(dataRowView.Row.ItemArray[5]) == 2) |
{ |
((GridViewComboBoxColumn)((RadGridView)sender).Columns["ActivityTypeID"]).ItemsSource = ComboBoxValues.GetComboValues(dtActivityType.Select("ID > 2000")); |
} |
} |
catch { } |
} |
private void OnSubChildGridLoaded(object sender, RoutedEventArgs e) |
{ |
try |
{ |
var dataRowView = (DataRowView)((RadGridView)sender).ParentRow.DataContext; |
var ds = dataRowView.DataView.Table.DataSet; |
var childData = dataRowView.CreateChildView(ds.Relations["SubBudgetRelation"]); |
((RadGridView)sender).ItemsSource = childData; |
//סינון הערכים בגריד לפי סוג פעילות |
if (((ComboBoxValues.ComboValues)cmbActivityType.SelectedValue).Id != 0) |
{ |
childData.RowFilter="ActivityTypeID=" + ((ComboBoxValues.ComboValues)cmbActivityType.SelectedValue).Id; |
((RadGridView)sender).ItemsSource = childData; |
} |
else |
{ |
((RadGridView)sender).ItemsSource = null; |
((RadGridView)sender).ItemsSource = childData; |
} |
//סינון הערכים בתיבת הבחירה של סוג פעילות |
if (Convert.ToInt32(dataRowView.Row.ItemArray[5]) == 1) |
{ |
((GridViewComboBoxColumn)((RadGridView)sender).Columns["ActivityTypeID"]).ItemsSource = ComboBoxValues.GetComboValues(dtActivityType.Select("ID < 2000")); |
} |
if (Convert.ToInt32(dataRowView.Row.ItemArray[5]) == 2) |
{ |
((GridViewComboBoxColumn)((RadGridView)sender).Columns["ActivityTypeID"]).ItemsSource = ComboBoxValues.GetComboValues(dtActivityType.Select("ID > 2000")); |
} |
} |
catch { } |
} |
public partial class Window1 : Window { Entities entities; PARENT parent; bool saved = false; public Window1() { InitializeComponent(); entities = new Entities(); parent = PARENT.CreatePARENT(Guid.NewGuid().ToString(), "00000"); gridViewChild.ItemsSource = parent.Child; } private void buttonOk_Click(object sender, RoutedEventArgs e) { entities.SaveChanges(); } private void buttonCancel_Click(object sender, RoutedEventArgs e) { } private void tabItemParent_LostFocus(object sender, RoutedEventArgs e) { if (!saved) { // Create the parent parent.FIRST_NAME = this.textBoxFirstName.Text; parent.LAST_NAME = this.textBoxLastName.Text; parent.MIDDLE_NAME = this.textBoxMiddleName.Text; parent.ZIP = this.textBoxZipCode.Text; entities.AddToPARENT(parent); saved = true; } } private void gridViewChild_AddingNewDataItem(object sender, Telerik.Windows.Controls.GridView.GridViewAddingNewEventArgs e) { // Entity Framework supports identity (server side generated) keys but we // must provide a default key value first. CHILD child = CHILD.CreateCHILD(0, "Test"); parent.ChildProfile.Add(child); e.NewObject = child; } } |
DataMemberBinding="{Binding Path=AAA.BBB.CCC}" |
I want to do the following which I can do with most of the itemcollections in the ms toolbox.
I want to be able to bind a custom property on an object to the SelectedProperty of a row in a gridview. The result would be that you could select multiple rows in a gridview and then each of the objects in the list that the Grid was bound to would have their IsSelectedProperty set to true.
Example of TreeView:
So each TreeViewItem IsSelected property is bound to the bound objects IsSelectedProperty.
<
Style x:Key="{x:Type TreeViewItem}" TargetType="{x:Type TreeViewItem}">
<Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
....
....
</Style>
Is this possible with the GridView?
Thanks,