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
370
XamDataGrid HyperLinkCell and Command implementation in MVVM
posted

I have a XamDataGrid with a hyperlink cell. I'm trying to bind the Command on the Hyperlink cell to the command in the ViewModel, but having difficulty doing that.

Below is the XAML for the XamDataGrid

<ig:XamDataGrid DataSource="{Binding Report}" Theme="Office2k7Black" Height="600" Width="auto" ActiveDataItem="{Binding ActiveException, Mode=TwoWay}">
                       
                        <ig:XamDataGrid.Resources>
                            <Style TargetType="{x:Type ig:CellValuePresenter}" x:Key="hyperlinkCell">
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate TargetType="{x:Type ig:CellValuePresenter}">
                                            <TextBlock Margin="{TemplateBinding Padding}">
                                                <Hyperlink NavigateUri="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Value}" Command="{Binding LoadDetailReport}">
                                                    <TextBlock Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Value}">
                                                    </TextBlock>
                                                </Hyperlink>
                                            </TextBlock>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>

                        </ig:XamDataGrid.Resources>
                        <ig:XamDataGrid.FieldLayoutSettings>
                            <ig:FieldLayoutSettings AutoGenerateFields="False"/>
                        </ig:XamDataGrid.FieldLayoutSettings>
                        <ig:XamDataGrid.FieldSettings>
                            <ig:FieldSettings AllowFixing="NearOrFar" AllowEdit="False" Width="auto" Height="auto"  />
                        </ig:XamDataGrid.FieldSettings>

                        <ig:XamDataGrid.FieldLayouts>
                            <ig:FieldLayout>
                                <ig:FieldLayout.Fields>
                                    <ig:Field Name="Division" Label="Division">
                                        <ig:Field.Settings>
                                            <ig:FieldSettings  AllowResize="False" />
                                        </ig:Field.Settings>
                                    </ig:Field>
                                    <ig:Field Name="Cluster" Label="Cluster" />
                                    <ig:Field Name="Productline" Label="Product Line" />
                                    <ig:Field Name="Mainbook" Label="Risk Group" Visibility="Collapsed"/>
                                    <ig:Field Name="Subbook" Label="Sub Book" Visibility="Collapsed"/>    
                                    <ig:Field Name="Cobdate" Label="Cob Date"/>
                                   
                                    <ig:Field Name="TotalTrades" Label="Total Trades">
                                        <ig:Field.Settings>
                                            <ig:FieldSettings CellValuePresenterStyle="{StaticResource hyperlinkCell}"/>
                                        </ig:Field.Settings>
                                    </ig:Field>
                                    <ig:Field Name="TotalExceptions" Label="Total Exceptions"/>
                                    <ig:Field Name="LiveTradesWithoutPVs" Label="Live Trades Without PVs"/>
                                    <ig:Field Name="ZeroPVCount" Label="Zero PV Count">
                                        <ig:Field.Settings>
                                            <ig:FieldSettings CellValuePresenterStyle="{StaticResource hyperlinkCell}"/>
                                        </ig:Field.Settings>
                                    </ig:Field>
                                       
                                    <ig:Field Name="StalePVCount" Label="Stale PV Count"/>
                                    <ig:Field Name="RegressedPVCount" Label="Regressed PV Count"/>
                                    <ig:Field Name="TotalExceptionsValidated" Label="Total Exceptions Validated"/>
                                    <ig:Field Name="TotalExceptionsNotValidated" Label="Total Exceptions Not Validated"/>


                                </ig:FieldLayout.Fields>
                            </ig:FieldLayout>
                        </ig:XamDataGrid.FieldLayouts>
                    </ig:XamDataGrid>

 

 

This is the error I see in the output window

System.Windows.Data Error: 39 : BindingExpression path error: 'LoadDetailReport' property not found on 'object' ''DataRecord' (HashCode=15172893)'. BindingExpression:Path=LoadDetailReport; DataItem='DataRecord' (HashCode=15172893); target element is 'Hyperlink' (HashCode=57769674); target property is 'Command' (type 'ICommand')

 

From the error, I'm assuming that the parent DataContext which is the ViewModel is not visible to the Cell in which I have the hyperlink,

 

Can anybody give me some direction on this. Any help very much appreciated.

 

Thanks,

Shravan

Parents Reply Children
No Data