Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1285
Loading rows and Columns dynamically
posted

Hi,

As per my requirement, I need to load the rows and columns dynamically.

So I used 2 classes one is to get the Column name and type ; and another class to get row information.

I took data table and  created the Columns as ColumnInfo class and also updated rows info[From RowsInfo class].

And depends upon Type info from ColumnInfo class(like,TextBox,ComboBox,TextBlock) I created different styles in Xaml respectively.

 Later I binded to DataTable to XamDatagrid.

I used below style for one of Field through code behind

<Style x:Key="InCellStyle" TargetType="{x:Type igDP:CellValuePresenter}" >
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}" >
<Border CornerRadius="2" Name="MainBorder" BorderThickness="2" BorderBrush="{Path = BorderColor}">
<StackPanel Orientation="Horizontal">
<TextBlock x:Name="TextBlock" Text="{Binding Path= Value, RelativeResource={RelativeResource Mode=TemplatedParent} }" />

</StackPanel>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

Once i applied above style, I am able to see the Data in cell but not border Color.

I observered following error in output window of Visual studio

>>

System.Windows.Data Warning: 40 : BindingExpression path error: 'BorderColor' property not found on 'object' ''DataRecord' (HashCode=5604335)'. BindingExpression:Path=BorderColor; DataItem='DataRecord' (HashCode=5604335); target element is 'Border' (Name=''); target property is 'BorderBrush' (type 'Brush')

<<

Could you please let me , how to resolve the above issue and get the border for specific cell.

Thank you,

Chandra