I am using a GRadGridView("CustomerRadGrid") which is initially bounded to a empty ObservableCollection(CustomerCollection) and RadButton. The User should be able to add Rows to the Grid and Add Button ("AddCustomerBttn") adds all rows with user entered values to the ObservableCollection(CustomerCollection). I was able to get the value of the Fisrt Cell with this code.
string custName = row.ChildrenOfType<GridViewCell>().Where(c => c.Column.UniqueName == "CustomerName").FirstOrDefault().Value.ToString();
How to get value of GridViewDataColumn(CheckBox) in ViewModel?
View
<telerik:RadGridView ItemsSource="{Binding CustomerCollection,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
AutoGenerateColumns="False"
CanUserInsertRows="True" ShowInsertRow="True"
Name="CustomerRadGrid">
<telerik:GridViewMaskedTextBoxColumn UniqueName="CustomerName" Header="Name" DataMemberBinding="{Binding FirstName}" MaskType="None"/>
<telerik:GridViewDataColumn UniqueName="IsMail">
<telerik:GridViewDataColumn.Header>
<StackPanel>
<TextBlock Text="Mailing and Shipping Address Same?" />
</StackPanel>
</telerik:GridViewDataColumn.Header>
<telerik:GridViewDataColumn.CellTemplate>
<DataTemplate>
<StackPanel HorizontalAlignment="Center">
<CheckBox IsChecked="{Binding Path=IsAddressesSame, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/ >
</StackPanel>
</DataTemplate>
</telerik:GridViewDataColumn.CellTemplate>
</telerik:GridViewDataColumn>
</telerik:RadGridView>
<telerik:RadButton Name="AddCustomerBttn" Content="Add"
Command="{Binding AddCustomerCommand
CommandParameter="{Binding ElementName=CustomerRadGrid}"/>
Model
public class Customer : ViewModel.ViewModelBase
{
string name;
public string Name //Product
{
get { return name; }
set { name = value; NotifyPropertyChanged("Name"); }
}
bool isAddressesSame;
public bool IsAddressesSame
{
get { return IsAddressesSame; }
set { IsAddressesSame = value;NotifyPropertyChanged("IsAddressesSame "); }
}
}
}
ViewModel:
ObservableCollection<Customer> customerCollection = new ObservableCollection<Customer>();
public ObservableCollection<Customer> CustomerCollection
{
get { return customerCollection; }
set { customerCollection = value; NotifyPropertyChanged("CustomerCollection"); }
}
#region AddCustomerCommand //Add
public ICommand AddCustomerCommand { get; private set; }
public HomeViewModel()
{
AddCustomerCommand = new RelayCommand(Execute_AddCustomerCommand, CanExecute_AddCustomerCommand);
}
public void Execute_AddCustomerCommand (object parameter)
{
RadGridView rGridView = (RadGridView)parameter;
IList<GridViewRow> gViewRows = rGridView.ChildrenOfType<GridViewRow>().ToList();
foreach (GridViewRow row in gViewRows)
{
string custName = row.ChildrenOfType<GridViewCell>().Where(c => c.Column.UniqueName == "CustomerName").FirstOrDefault().Value.ToString();
bool addressSame ;//Get Value from the .
//How to get value from GridViewDataColumn CheckBox(True if checked, False if unchecked)
Customer temp = new Customer()
{
Name = custName,
IsAddressSame = addressSame
};
CustomerCollection.Add(temp);
}
}
public bool CanExecute_AddCustomerCommand (object parameter)
{
return true;
}
#endregion
Thank you,
-Prathibha
<
telerik:RadTreeView
Margin
=
"8"
ItemsSource
=
"{Binding treeRoot}"
ItemTemplate
=
"{StaticResource Level1Template}"
IsLineEnabled
=
"True"
SelectionChanged
=
"JobDesign_SelectionChanged"
x:Name
=
"JobDesign"
/>
<
HierarchicalDataTemplate
x:Key
=
"Level3Template"
>
<
TextBlock
Text
=
"{Binding Name}"
/>
</
HierarchicalDataTemplate
>
<
HierarchicalDataTemplate
x:Key
=
"Level2Template"
ItemTemplate
=
"{StaticResource Level3Template}"
ItemsSource
=
"{Binding Level3}"
>
<
TextBlock
Text
=
"{Binding Name}"
/>
</
HierarchicalDataTemplate
>
<
HierarchicalDataTemplate
x:Key
=
"Level1Template"
ItemTemplate
=
"{StaticResource Level2Template}"
ItemsSource
=
"{Binding Level2}"
>
<
TextBlock
Text
=
"{Binding Name}"
/>
</
HierarchicalDataTemplate
>
public class Level1
{
public Level1()
{
this.Level2 = new List<
Level2
>();
}
public string Name
{
get;
set;
}
public List<
Level2
> Level2
{
get;
set;
}
}
public ObservableCollection<
Level1
> treeRoot { get; private set; }
Level1 jobPlanning = treeRoot.Where(t => t.Name.Equals("Job Planning")).Single();
jobPlanning.Level2 = new List<
Level2
>();
Level2 operation = new Level2()
{
Name = "New Item"
};
this.OnPropertyChanged(() => this.treeRoot);
Hi Team,
I am using WPF Radlistbox with MVVM pattern,
Here is my code.
<
Style x:Key="DraggableListBoxItem" TargetType="telerik:RadListBoxItem">
<
Setter Property="telerik:DragDropManager.AllowCapturedDrag" Value="True" />
</
Style>
<telerik:RadListBox>
<
telerik:RadListBox.DragVisualProvider>
<
telerik:ScreenshotDragVisualProvider />
</
telerik:RadListBox.DragVisualProvider>
<
telerik:RadListBox.DragDropBehavior>
<
telerik:ListBoxDragDropBehavior />
</
telerik:RadListBox.DragDropBehavior>
</
telerik:RadListBox>
I have source listbox and target listbox,
1 ) while drag and drop items from source listbox to target , the draged items from source should not be removed.
2) Taget List box should not allow any duplicate item(s) to drop.
these conditions should be same for single selection and Multiselection
3) Drag and drop on Source listbox should be disabled.
along with I need the follwing features for Radlist box.
1)Multi-select available on BOTH sides and on all operations (right click, add, drag n drop) available
2)Multi-select is “sticky†(ie don’t need to use Ctrl) with reset button (clear selections). Add or double click operation will also reset.
3)Use of Shift+click will select everything in between last select.
4)Either box could have multiple columns (in which headings are needed)
5)Enable Right Clik
6)To reorder right side
7)Items selected on the right, still appear on the left
8)Add button is sometimes available
9)Double-click on left side does an add (one line only), on right side does a remove (one line only)
10???Filter (sometimes available), generally radio button with the first (default) option being “Allâ€. This allows for “one†click switching between (for example Bcast and cable)
Can any one help me to resolve these features.
Thanks
Suresh.S
How can I disable cell selection or remove selected cell border in GridView.