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
125
How to access a control template of a unbound field?
posted

XAML style

<Style TargetType="{x:Type igDP:CellValuePresenter}" x:Key="buttonCell">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}">
                   <Button Content="{TemplateBinding Content}" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

C# code

UnboundField f = new UnboundField();
f.Name = "Unbound Field";
f.Settings.CellValuePresenterStyle = Application.Current.Resources["buttonCell"]

I wanted to access the control template of this unbound field from code. Can you help me with this?

Parents
No Data
Reply
  • 138253
    Offline posted

    Hello,

     

    It has been a while since you have made your post, in case you still need support I will be glad to assist you further. I suppose the other community members can benefit from this answer as well. I have been looking into your post and I suggest you use the following code in order to get the Element in the CellValuePresenter:

     

    Button button = Utilities.GetDescendantFromType(CellValuePresenter.FromCell(xamDataGrid1.ActiveCell),typeof(Button),true) as Button;

     

    Feel free to write me if you have further questions.

Children
No Data