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
380
How to bind to Record.Index?
posted

I have a custom user control ( 'InventoryImageBtn' )  that I'm embedding in an unboud field of my XamDataGrid. I bind it's source to a bound field that contains a path to an image if it exists (in this case the control displays the image), if not it just contains an '0' (in which case the control displays an 'upload' image button.

The control has a dependency property named 'Index' that I want to bind to the Record.Index that the control gets placed in. Can you tell me the correct syntax for binding to this property?

The CellValuePresenter style for the control:

<Style TargetType="{x:Type igDP:CellValuePresenter}" x:Key="ImgBtnField">

  <Setter Property="Template">

    <Setter.Value>

      <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}">

        <local:InventoryImageBtn x:Name="ImageBtn" ButtonMode="Image" Index="{Binding Record.Index}" ImageSource="{Binding Cells[Image].Value}" Width="75" Height="75"/>

        <ControlTemplate.Triggers>

<DataTrigger Binding="{Binding Cells[Image].Value}" Value="0">

  <Setter TargetName="ImageBtn" Property="ButtonMode" Value="Button"/>

</DataTrigger>

        </ControlTemplate.Triggers>

      </ControlTemplate>

    </Setter.Value>

  </Setter>

</Style>