I'm implementing multilanguage in my program which is using the XamDataGrid.
But, I'm having some trouble with binding the Label-attribute of the Field-tag to a property.
XAML:
<igDP:FieldLayout Key="master"> <igDP:Field Name="ShortName" Label="{Binding Test}" /> <igDP:Field Name="Name" Label="Name" /> <igDP:Field Name="Min" Label="Minimum" /> <igDP:Field Name="Prob" Label="Probably" /> <igDP:Field Name="Max" Label="Max" /> <igDP:Field Name="Mean" /> <igDP:Field Name="Calcs" /> </igDP:FieldLayout>
C#:
public string Test { get { return "Test"; } }
The (very simple) binding works perfectly on other WPF-controls such as a Button. But why doesn't it work on the XamDataGrid Field?
Hello,
I have been looking into your code and I created a sample project for you using it with a little modification, so now it has the functionality you want. Basically I changed the binding of the Tag. The RelativeSource is set to the DataREcordPresenter. This way you are able to get any Record's TaskDefID Property. Please let me know if this helps you or you need further assistance on this matter.
Looking forward for your reply.
Any inputs would be helpful!
I'm trying to create the DataTemplate of a Field as mentioned below where I need to set the Tag property of a Label to "" property defined on a DataSource.
<igDP:Field Name="Added" Label="# Added" Width="50" > <igDP:Field.Settings> <igDP:FieldSettings> <igDP:FieldSettings.CellValuePresenterStyle> <Style TargetType="{x:Type igDP:CellValuePresenter}"> <Setter Property="ContentTemplate"> <Setter.Value> <DataTemplate> <Label Width="Auto" Tag="{Binding Path=DataContext.TaskDefID, RelativeSource={RelativeSource AncestorType={x:Type UI:EclpGrid}}}" Content="{Binding .}" x:Name="Added" Click="TaskListAddedClick" HorizontalAlignment="Center" Margin="5" /> </DataTemplate> </Setter.Value> </Setter> </Style>
</igDP:FieldSettings.CellValuePresenterStyle> </igDP:FieldSettings> </igDP:Field.Settings> </igDP:Field>
DataSource is -
public class TskStatus { public string TaskDefName { get; set; } public int TaskDefID { get; set; } public long Added { get; set; } }
private List<TskStatus> _taskDefList; public List<TskStatus> TaskDefList { get { return _taskDefList; } set { _taskDefList = value; } }
_taskDefList = new List<TskStatus> { new TskStatus { TaskDefName = "Task 1", Added = 20, TaskDefID=1}, new TskStatus { TaskDefName = "Task 2", Added = 120, TaskDefID=3}, new TskStatus { TaskDefName = "Task 3", Added = 120, TaskDefID=2 }};
I need to set the Label.Tag property for the selected record in grid to TaskDefID but it's always null. KIndly Suggest.
Hello Christian,
I have modified the sample from some of my previous posts, so now if you change the Property to which the Label is bound it will update. Basically I implemented the InotifyPropertyChnaged interface to the class that held this Property and change the way you get the Types collection.
Hope this helps you.
Hello Stefan,
The bindings of the labels refers to a dictionary in my ViewModel, which apparently gets populated at some point after the xamDataGid has been loaded.
I therefor need to make some kind of "refresh" somewhere after the events above has happened.
Is this possible at all?