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

  • Home
  • SEARCH
  • 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 6787289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:20:54+00:00 2026-05-26T17:20:54+00:00

I builded a RibbonGroupBox like this in a C# file: public class TextControl :

  • 0

I builded a RibbonGroupBox like this in a C# file:

public class TextControl : RibbonGroupBox
{
    public TextControl()
    {
        const double widthOfComboBoxes = 150;

        Binding fontsBinding = new Binding();
        fontsBinding.Source = (TextControlVM)DataContext;
        fontsBinding.Path = new System.Windows.PropertyPath("Fonts");
        fontsBinding.Mode = BindingMode.TwoWay;

        Binding fontSizeBinding = new Binding();
        fontSizeBinding.Source = (TextControlVM)DataContext;
        fontSizeBinding.Path = new System.Windows.PropertyPath("FontSize");
        fontSizeBinding.Mode = BindingMode.TwoWay;

        /* Combobox for the fonts (Arial, etc.) */
        Fluent.ComboBox fontCombo = new Fluent.ComboBox();
        fontCombo.SetBinding(Fluent.ComboBox.ItemsSourceProperty, fontsBinding);
        fontCombo.SelectedItem = ((TextControlVM)DataContext).DefaultFont;
        fontCombo.Width = widthOfComboBoxes;
        this.AddChild(fontCombo);

        /* Combobox for the fontsizes */
        Fluent.ComboBox fontSizeCombo = new Fluent.ComboBox();
        fontSizeCombo.SetBinding(Fluent.ComboBox.ItemsSourceProperty, fontSizeBinding);
        fontSizeCombo.SelectedItem = ((TextControlVM)DataContext).DefaultFontSize;
        fontSizeCombo.Width = widthOfComboBoxes;
        this.AddChild(fontSizeCombo);
    }
}

I furthermore have a viewmodel (TextControlVM) that contains Properties for Fonts, FontSize, DefaultFont and DefaultFontSize.

When I now use this in another module like this, the DataContext in the above example is null:

<Fluent:RibbonTabItem Header="Export">
    <TextControl DataContext="{Binding DataContext.TextControl}"/>
</Fluent:RibbonTabItem>

When I build the RibbonGroupBox with XAML code everything works fine, so I want to do what XAML automatically does. How can I do that?

Background: I want to use the RibbonGroupBox in several modules. That is why I build it with C#-Code, so that I can access it dynamically. The DataContext will change dependend on the call.

  • 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-05-26T17:20:54+00:00Added an answer on May 26, 2026 at 5:20 pm

    The DataContext is implied in a binding automatically, so you are essentially binding to RibbonTabItem.DataContext.DataContext.TextControl, which doesn’t exist

    To bind to RibbonTabItem.DataContext.TextControl, simply leave the extra DataContext out of the binding

    <Fluent:RibbonTabItem Header="Export">
        <TextControl DataContext="{Binding TextControl}"/>
    </Fluent:RibbonTabItem>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(Title); builder.setItems(items, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog,
I'm new to the world of iOS programming and MacOS at all, and this
Can someone explain this to me: I builded an really simple wcf service for
AlertDialog.Builder alt_bld = new AlertDialog.Builder(this); when i wrote this error is shawn that The
i've builded an asp.net mvc website,when i click the file->save page as button in
The default rails XML builder escapes all HTML, so something like: atom_feed do |feed|
I'm just preparing the release of a library site builded in asp.net: http://213.133.103.5/gramma_prod/Site/Index.aspx All
i have little experience with Liferay, builded a couple of sites with static content
I'm developing a dll that uses libcurl. I builded lib with vc6curlsrc.dsw project (I
JavaFX 2.0 GUI builder is removed for Linux? Like in old JavaFX we had

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.