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
1564
How to handle the "DataPresenterCommands.StartEditMode" event in a custom DataRecordPresenter ?
posted

Hi,

 

In my xamDataPresenter I have create a custom "DataRecordPresenter" where I have something like this :

<Style TargetType="{x:Type igDP:DataRecordPresenter}">
  <
Setter Property="HeaderAreaBackground" Value="{x:Null}"/>
  <
Setter Property="Template"> .... </Setter
  <Setter Property="TemplateCardView">
    <
Setter.Value>
      <
ControlTemplate TargetType="{x:Type igDP:DataRecordPresenter}">
        <
StackPanel>

          <vov:VideoThumbnail IsSelected="{Binding IsSelected}" MediaData="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=DataRecord.DataItem}"/>

<ContentPresenter
x:Name="PART_RecordContentSite"
Visibility="Collapsed"
Content="{TemplateBinding DataContext}"
ContentTemplate="{TemplateBinding RecordContentAreaTemplate}"/>

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

Now in my code I call this code to start the edition :         xdgMedias.ExecuteCommand(DataPresenterCommands.StartEditMode);

But I would like to handle the corresponding "event" in my "vov:VideoThumbnail" control.

Do you know how I can do this ?

Parents
No Data
Reply
  • 9694
    posted

    There are a few ways you can do this. As you probably have discovered, you cannot simply access the VideoThumbnail since it is declared in a template.

    One way is to use the VisualTreeHelper to look for the ViewoThumbnail during runtime. The object is embedded in the Field and can be accessed through the Field hierarchy.

    A simpler way would be to provide an event for when the VideoThumbnail is initialized. In the event handler you can store a reference to the object for later access.

    The great thing about WPF is there are probably several other solutions.

    Thanks,

Children
No Data