RadPathButton and ContentTemplateSelector

2 Answers 117 Views
Buttons
Peter
Top achievements
Rank 2
Iron
Iron
Veteran
Peter asked on 10 May 2021, 11:29 AM | edited on 10 May 2021, 11:30 AM

Hello,

I am using the ContentTemplateSelector-Property of the RadPathButton, but nothing happens. Is there some trick to activate this feature?

My xaml:

        <utils:MessageDirectionTemplateSelector x:Key="messageDirectionTemplateSelector">
            <utils:MessageDirectionTemplateSelector.DecEditDataTemplate>
                <DataTemplate>
                    <ContentControl ContentTemplate="{StaticResource icon:outMessage}"/>
                </DataTemplate>
            </utils:MessageDirectionTemplateSelector.DecEditDataTemplate>
            <utils:MessageDirectionTemplateSelector.HexEditDataTemplate>
                <DataTemplate>
                    <ContentControl ContentTemplate="{StaticResource icon:inMessage}"/>
                </DataTemplate>
            </utils:MessageDirectionTemplateSelector.HexEditDataTemplate>
        </utils:MessageDirectionTemplateSelector>


<telerik:RadPathButton Content="{Binding DataContext, RelativeSource={RelativeSource Self}}"
                                       ContentPlacement="Right"
                                       ContentTemplateSelector="{StaticResource messageDirectionTemplateSelector}"/>

 

The Selector-Class:

public class MessageDirectionTemplateSelector : DataTemplateSelector { public override DataTemplate SelectTemplate(object item, DependencyObject container) { if (item is MessageItem) { return Properties.Settings.Default.CanIdHex ? HexEditDataTemplate : DecEditDataTemplate; } if (item is MessageSignalItem) { return Properties.Settings.Default.MuxValueHex ? HexEditDataTemplate : DecEditDataTemplate; } if (item is EnumValueItem) { return Properties.Settings.Default.EnumValueHex ? HexEditDataTemplate : DecEditDataTemplate; }

return null; }

public DataTemplate HexEditDataTemplate { get; set; } public DataTemplate DecEditDataTemplate { get; set; } }

regards,

Tobias

2 Answers, 1 is accepted

Sort by
0
Vicky
Telerik team
answered on 12 May 2021, 06:09 AM

Hello Tobias,

Thanks for the provided code snippets - they were of great help.

I used them to create a similar sample application to try and replicate the described behavior. Everything works as expected on my side.
Is it possible for you to create a working WPF application which demonstrates the issue so that I could better assist you?

I am looking forward to your reply.

Best Regards,
Vicky
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

0
Peter
Top achievements
Rank 2
Iron
Iron
Veteran
answered on 12 May 2021, 06:55 AM

Hello Vicky,

the issue is gone. It works as expected, don't know what I'm doing wrong in first place. Sorry for the confusion...

regards,

Tobias

Tags
Buttons
Asked by
Peter
Top achievements
Rank 2
Iron
Iron
Veteran
Answers by
Vicky
Telerik team
Peter
Top achievements
Rank 2
Iron
Iron
Veteran
Share this question
or