Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8893095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:09:41+00:00 2026-06-14T23:09:41+00:00

I am using the convention-based binding from Caliburn.Micro, but I have a small issue:

  • 0

I am using the convention-based binding from Caliburn.Micro, but I have a small issue:

How do I set the property that my binding should bind to? If I create a control with x:Name="SomeProperty", how do I choose if the value of SomeProperty should be binded to the Value Property of my control, the OnClick Event of my control or something different, like the Content or the Tag property?

Example: I have this HyperlinkButton that I want to bind to a specific URL, and I want to bind the OnClick to an event handler in my ViewModel.

<HyperlinkButton x:Name="BookDetailsViewModel_InfoLink" Content="Read more" />

The Content property however is not filled with Read more but with the value of the URL. In this example, how do I:

  • Set the navigation URI to the value of the URL in my ViewModel property
  • Set the content to “Read more”
  • Specify an event handler in my ViewModel that will handle the click

Can anyone help me please?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T23:09:42+00:00Added an answer on June 14, 2026 at 11:09 pm

    You can customise the ConventionManager per element type in CM. The default out-of-box implemententation is applied to any element which doesn’t have an explicit customisation

    To add a new convention you just simply call ConventionManager.AddElementConvention

    The method looks like this (from CM source)

    /// <summary>
    /// Adds an element convention.
    /// </summary>
    /// <typeparam name="T">The type of element.</typeparam>
    /// <param name="bindableProperty">The default property for binding conventions.</param>
    /// <param name="parameterProperty">The default property for action parameters.</param>
    /// <param name="eventName">The default event to trigger actions.</param>
    public static ElementConvention AddElementConvention<T>(DependencyProperty bindableProperty, string parameterProperty, string eventName)
    {
        return AddElementConvention(new ElementConvention
        {
            ElementType = typeof(T),
            GetBindableProperty = element => bindableProperty,
            ParameterProperty = parameterProperty,
            CreateTrigger = () => new EventTrigger { EventName = eventName }
        });
    }
    

    As you can see, it takes a few args – you need to pass the default property for bindings, actions, and triggers e.g.

    ConventionManager.AddElementConvention<HyperlinkButton>(HyperlinkButton.NavigateUri, "NavigateUri", "Click");
    

    (assuming the click event is called Click)

    Since you aren’t binding the Content property any more (because the convention is to now bind NavigateUri) you can just leave that as-is and it should remain ‘Read more…’

    So now you have a HyperlinkButton control which should bind by convention to the NavigateUri, and call the method which shares it’s name when the Click event is triggered.

    Edit:

    I might make a clarification that I don’t think you can bind to both a method and a property on the same VM since you can’t have a method and a property that share the same name, but I’m sure CM would bubble the action message up the VM hierarchy if you didn’t have the appropriate method on the VM… not tried it though. To bind the actions see my other edit below

    Don’t forget, you could always just use the explicit syntax for all of this!

    <HyperlinkButton Content="Read more..." NavigationURI="{Binding SomeUri}" cal:Message.Attach="[Event Click] = [Action HyperlinkClicked($this.NavigateUri)" />
    

    but it’s probably better to go the convention route 🙂

    Edit:

    Might add how to get convention to grab the property value from the hyperlink –

    <HyperlinkButton x:Name="SomeLink" Content="Read more..." cal:Message.Attach="HyperlinkClicked(SomeLink)" />
    

    CM knows that since you set NavigateUri as the default action parameter, it should grab this and pass it to the method that you specified in the action binding. I’m wondering if $this will also work (you probably would need $this.NavigateUri). You can do this across controls e.g.

    <TextBox x:Name="SomeTextBox" />
    <HyperlinkButton x:Name="SomeLink" Content="Read more..." cal:Message.Attach="HyperlinkClicked(SomeTextBox)" />
    

    The above would pass the Text property of the textbox to the HyperlinkClicked method by default.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How do you apply a ValueConverter to a convention-based Caliburn.Micro binding? or do you
I need to validate on exceptions when doing binding. Is this possible using Caliburn.Micro?
I'm trying register presenters with Windsor using the convention based method but trying to
I've been using NHibernate for a while now but mostly with convention based auto
I have a C# program that is supposed to pull data from a small,
We are using Fluent NH with convention based mapping. I have the following: public
Very simple question, but I want to start using a consistent naming convention for
I've implemented a web based instant messaging / chat feature using http binding and
I have a Sharp Architecture based app using Fluent NHibernate with Automapping. I have
I have a model that requires loading external data from an auxiliary source. A

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.