Federerer / Notifications.Wpf

Toast notifications for WPF
MIT License
657 stars 142 forks source link

CustomTemplateSelector not loading #27

Open shandysawyer opened 2 years ago

shandysawyer commented 2 years ago

Having an issue getting the custom error message template to load. I am using the example you provided in your sample. The issue I am seeing is the object being passed is not a string but a NotificationContent object, so its skipping loading the template: image

Is the sample old, or is this bug, or do I have my wiring wrong somewhere?

Federerer commented 2 years ago

It has been years since I used this last time, but IIRC you can define a template without overriding default template selector. Something like this:

    <Application.Resources>
        <Style TargetType="controls:Notification">
            <Style.Resources>
                <DataTemplate DataType="{x:Type local:YourModel}">
                    // Anything you want
                </DataTemplate>
            </Style.Resources>
        </Style>
    </Application.Resources>

I would probably use a dedicated class instead of trying to override the default template for NotificationContent because I don't see an easy way to override just error template without changing them all. I hope it helped 😄