|
Thanks for the reply. SetBinding doesn't exist on the GridViewDataColumn type though... I did figure it out, however:
Dim c = New Telerik.Windows.Controls.GridViewDataColumn With {.Header = sched.ShipName,
.IsReadOnly = True,
.IsFilterable = True,
.IsSortable = True,
.IsGroupable = False,
.ShowFieldFilters = True,
.ShowDistinctFilters = False,
.DataMemberBinding = New System.Windows.Data.Binding With {.Converter = New ColumnConverter(),
.ConverterParameter = (s + 1).ToString}
}
Dim backgroundBinding As New System.Windows.Data.Binding With {.Converter = New BackgroundColorConverter,
.ConverterParameter = (s + 1).ToString}
backgroundBinding.Source = c
System.Windows.Data.BindingOperations.SetBinding(c, Telerik.Windows.Controls.GridViewDataColumn.BackgroundProperty, backgroundBinding)
columnCollection.Add(c)
|
|
|
|
|
USAFHokie80 wrote: SetBinding doesn't exist on the GridViewDataColumn type
The BindingOperations.SetBinding method is an extension method. If you import the System.Windows.Data namespace, you'll be able to call it as c.SetBinding(...) .
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi,
You can use DataGrid_AutoGeneratedColumns() event and set the datagrid.ColumnHeaderStyle,
can set background color ,fore-color etc,with help ColumnHeaderStyle Property.
I hope that it is useful for you.
Thanks
Mohit Saxena
mohit Saxena
|
|
|
|
|
Hi.
I have 2 DatePicker control in WPF Windows (start date and end date).
Where User should be able to select start date and end date.
End date should be lass then and not equal to end date.
I want to give validation when user leave the end date(DatePicker control) at that time.
|
|
|
|
|
|
I have a SL/WPF application that populates a datagrid. The button contains this code:
MyDomainContext context = new MyDomainContext();
dataGrid1.ItemsSource = context.DBTables;
context.Load(context.GetTwoDataBasesQuery());
The DomainServices.cs contains:
public IQueryable<DBTable>GetTwoDataBases()
{
return this.ObjectContext.DBTables;
}
This code works fine but returns all columns in the context
I need to return only two columns so changed is as follows
public IQueryable<DBTable>GetTwoDataBases()
{
return GetDBTables().Select(m => new { m.col1, m.col2 });
}
But code has errors, does not accept the "return" .
how do I get col1 and col2?
Many thanX
|
|
|
|
|
Can any one help me to write style for 2 textbox which should take input like Latitude , Longitude. with validation
|
|
|
|
|
|
And which format will be used - degrees, minutes, seconds, ...?
|
|
|
|
|
|
|
psst - Yogi say thank you properly and give him an up vote (little arrows beside the title)
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
We can expose a button as ActiveX contol method. Also we can expose a button as MEF plug-in. My question is can use MEF logic for exposing the button instead of exposing the button using ActiveX control. Please let me know the effectiveness of using the button in both ways. The usabilty of that button is for testing purpose.
|
|
|
|
|
I have a Radgridview contains some rows i need to preview the telerik radgridview items first then i need to print the specified document (if i have 5 radgridview items i need to display each row in each page with radgridview header.
|
|
|
|
|
Try this[^] - it may provide some insight.
Posting this on the Telerik forum might give you some solution.
|
|
|
|
|
My previous post about detecting property changes in the VM wasn't in depth enough, so I'm posting this
I have a grid of Jobs. Each job can have one or more employees.
The DataGrid's RowDetailsTemplate contains another grid to show the employees. So to parent grid is bound to a list of Jobs. The inner grid is bound to a list of Employees that is on the Job model.
The Job Model:
public class Job : _Base
{
private string _JobName = string.Empty;
public string JobName
{
get { return _JobName; }
set
{
if (_JobName != value)
{
_JobName = value;
RaisePropertyChanged("JobName");
}
}
}
private string _JobNumber = string.Empty;
public string JobNumber
{
get { return _JobNumber; }
set
{
if (_JobNumber != value)
{
_JobNumber = value;
RaisePropertyChanged("JobNumber");
}
}
}
private ObservableCollection<Employee> _Employees;
public ObservableCollection<Employee> Employees
{
get { return _Employees; }
set
{
if (_Employees != value)
{
if (_Employees != value)
{
_Employees = value;
RaisePropertyChanged("Employees");
}
}
}
}
private Employee _SelectedEmployee;
public Employee SelectedEmployee
{
get { return _SelectedEmployee; }
set
{
if (_SelectedEmployee != value)
{
if (_SelectedEmployee != value)
{
_SelectedEmployee = value;
RaisePropertyChanged("SelectedEmployee");
}
}
}
}
public Job()
{
Employees = new ObservableCollection<Employee>();
}
}
The Employee model
public class Employee : _Base
{
private string _EmployeeName = string.Empty;
public string EmployeeName
{
get { return _EmployeeName; }
set
{
if (_EmployeeName != value)
{
_EmployeeName = value;
RaisePropertyChanged("EmployeeName");
}
}
}
private bool _IsChecked = false;
public bool IsChecked
{
get { return _IsChecked; }
set
{
if (_IsChecked != value)
{
_IsChecked = value;
RaisePropertyChanged("IsChecked");
}
}
}
}
The XAML
<DataGrid ItemsSource="{Binding Jobs}"
SelectedItem="{Binding SelectedJob}"
AutoGenerateColumns="False">
<DataGrid.Columns>
<DataGridTextColumn Header="Job Name" Binding="{Binding JobName}" />
<DataGridTextColumn Header="Job Number" Binding="{Binding JobNumber}" />
</DataGrid.Columns>
<DataGrid.RowDetailsTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical">
<DataGrid ItemsSource="{Binding Employees}"
SelectedItem="{Binding SelectedEmployee}"
AutoGenerateColumns="False">
<DataGrid.Columns>
<DataGridCheckBoxColumn Binding="{Binding IsChecked}"/>
<DataGridTextColumn Binding="{Binding EmployeeName}"/>
</DataGrid.Columns>
</DataGrid>
<Button Margin="5"
Height="23"
Width="75"
HorizontalAlignment="Left"
Content="Remove"/>
</StackPanel>
</DataTemplate>
</DataGrid.RowDetailsTemplate>
</DataGrid>
The MainWindowViewModel
public class MainWindowViewModel : _Base
{
private ObservableCollection<Job> _Jobs;
public ObservableCollection<Job> Jobs
{
get { return _Jobs; }
set
{
if (_Jobs != value)
{
if (_Jobs != value)
{
_Jobs = value;
RaisePropertyChanged("Jobs");
}
}
}
}
private Job _SelectedJob;
public Job SelectedJob
{
get { return _SelectedJob; }
set
{
if (_SelectedJob != value)
{
if (_SelectedJob != value)
{
_SelectedJob = value;
RaisePropertyChanged("SelectedJob");
}
}
}
}
public MainWindowViewModel()
{
this.PropertyChanged += new PropertyChangedEventHandler(MainWindowViewModel_PropertyChanged);
}
void MainWindowViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if (e.PropertyName.Trim().ToLower() == "ischecked")
{
int x = 1;
}
}
}
I have a couple of questions:
1) The SelectedEmployee property on the Job model does not fire when I click an employee in the inner grid.
2) The MainWindowViewModel_PropertyChanged does not fire when an employee is selected.
3) Notice the button below the inner grid. How do I bind its command to MainWindowVM?
If it's not broken, fix it until it is
|
|
|
|
|
I have a data grid bound to a list of Job Models. The Job Model has a Job Name property.
I can tell when a row is selected because the grid's SelectedItem is set. But when the user changes some data in the grid, I'd like to do some things in the view mdoel.
When the user changes the Job Name on the active row in the grid, how can the View Model know about it?
Thanks!
If it's not broken, fix it until it is
|
|
|
|
|
Make sure that you have two-way databinding set in the textbox, and editing name in the active row will update the name property (I'm also assuming that you are updating the name field via the standard PropertyChanged event here; hence 2-way binding).
|
|
|
|
|
I think I wasn't clear.
What I want it to detect in the VM that a property on a model has changed. How do I set this up in the VM?
My models implement INotifyPropertyChanged. But I want to take action in the VM when a property on the model changes
[UPDATE]
I think what I want it to handle a Job_PropertyChanged event in the VM. But the Jobs are coming back from the DAL, so where/how do I wire up the event handler in the VM??
If it's not broken, fix it until it is
|
|
|
|
|
This is one of those cases where it make more sense to "break" the fall through to the model so that you handle the change in the VM, and then forward the result onto the model. It's a simple solution and doesn't require you to add any other events.
|
|
|
|
|
Ok, what I'm asking is HOW? What's the syntax? What does the code in the VM look like?
If it's not broken, fix it until it is
|
|
|
|
|
Let's assume you have a Model that looks like this:
public class MyModel : PropertyChangeBase
{
private string _name;
public string Name
{
get { return _name; }
set
{
if (_name == value) return;
_name = value;
RaisePropertyChanged("Name");
}
}
} Then, there's this VM:
public class MyViewModel : PropertyChanged
{
private MyModel _model;
public string Name
{
get { return _model.Name; }
set
{
if (_model.Name == value) return;
_model.Name = value;
RaisePropertyChanged("Name");
}
}
} Then, your view simply binds to the Name property on your model. It's nothing complicated.
|
|
|
|
|
Ugh, I hate when people do this .
Just subscribe to _model.OnPropertyChanged += ...; and check for the properties you are interested in.
Only time you want to write a new getter / setter IMO is when the original property doesn't support INPC or you need INPC to behave in a different way for said property.
|
|
|
|
|
SledgeHammer01 wrote: Only time you want to write a new getter / setter IMO is when the original property doesn't support INPC or you need INPC to behave in a different way for said property.
Indeed, and as he wants to do something a different way for said property, this is the simplest solution, especially as it doesn't involve managing the lifetime of a none weak event subscription just to stick to an idealistic view.
|
|
|
|
|
I tried it the way SledgeHammer suggested, on the SelectedRecord (bound to the SelectedItem in the DG) I had a -= before the change to remove existing bindings and a += after the change, worked Ok.
Haven't tried POHs method but I would have no compunction shattering the MVVM design if it suited my needs .
Never underestimate the power of human stupidity
RAH
|
|
|
|