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 7766181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:20:54+00:00 2026-06-01T15:20:54+00:00

In my apllication in each view I have a shared user control that each

  • 0

In my apllication in each view I have a “shared” user control that each view loads. this control contains just four buttons, but I need to change the content of each button depending by the view who loads it.
No problem until the content is just a string, but I don’t know how to do once I need to put as a content of a button some controls, like a grid with images and text.

I tried creating a local resource with a key, but I need to set Content=”{DynamicResource res}”, so from ViewModel I cannot have any binding to the content…

<UserControl x:Class="PlusMatic.Presentation.Views.SubViews.FrontendButtonsView"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" 
         d:DesignHeight="432" d:DesignWidth="211.2"
         DataContext="{Binding FrontendButtons, Source={StaticResource Locator}}" >

<Grid x:Name="LayoutRoot" Margin="0,0,0,5">
    <Grid.Resources>
        <Border x:Key="ButtonOneStructure">

                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition/>
                        <ColumnDefinition/>
                    </Grid.ColumnDefinitions>
                    <Image Grid.Column="0" Source="{Binding FlagPath}" Stretch="Uniform"  Margin="5"/>
                <Viewbox Stretch="Uniform" Grid.Column="1" >
                    <TextBlock TextWrapping="Wrap" Style="{DynamicResource BigTextBlockPlusMatic}" >
                                        <TextBlock.Inlines>
                                            <Run Text="{DynamicResource 103ita}" />
                                            <LineBreak />
                                            <Run Text="{DynamicResource 103eng}" />
                                            <LineBreak />
                                            <Run Text="{DynamicResource 103fra}" />
                                            <LineBreak />
                                            <Run Text="{DynamicResource 103deu}" />
                                            <LineBreak />
                                            <Run Text="{DynamicResource 103esp}" />
                                        </TextBlock.Inlines>
                    </TextBlock>
                </Viewbox>
            </Grid>

        </Border>
    </Grid.Resources>
    <Grid.RowDefinitions>
        <RowDefinition Height="0.25*"/>
        <RowDefinition Height="0.25*"/>
        <RowDefinition Height="0.25*"/>
        <RowDefinition Height="0.25*"/>
    </Grid.RowDefinitions>
    <Button x:Name="ButtonOne" Margin="0,5,10,5" Content="{DynamicResource ButtonOneStructure}" Grid.Row="0" Style="{DynamicResource FrontendButtonStyle}" />
    <Button x:Name="ButtonTwo" Margin="0,5,10,5" Content="{Binding ButtonTwoContent}" Grid.Row="1" Style="{DynamicResource FrontendButtonStyle}" />
    <Button x:Name="ButtonThree" Margin="0,5,10,5" Content="{Binding ButtonThreeContent}" Grid.Row="2" Style="{DynamicResource FrontendButtonStyle}" />
    <Button x:Name="ButtonFour" Margin="0,5,10,5" Content="{Binding ButtonFourContent}" Grid.Row="3" Style="{DynamicResource FrontendButtonStyle}" />
</Grid>

Any help appreciated!

L.

  • 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-01T15:20:55+00:00Added an answer on June 1, 2026 at 3:20 pm

    Following the suggestion, I’ve choosen to implement it having one data template and a trigger inside which helps me to switch between two different controlTemplate:

    <UserControl x:Class="PlusMatic.Presentation.Views.FrontendButtonsView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" 
             d:DesignHeight="432" d:DesignWidth="211.2"
             DataContext="{Binding FrontendButtons, Source={StaticResource Locator}}" >
    
    <Grid x:Name="LayoutRoot" Margin="0,0,0,5">
        <Grid.Resources>
    
            <!--Template per i bottoni frontend-->
            <!--Bottone uno-->
            <ControlTemplate x:Key="ButtonOneLangChangeControlTemplate" TargetType="{x:Type Control}">
                <Border>
                    <Grid >
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <Image Grid.Column="0" Source="{Binding Source={StaticResource Locator}, Path=FrontendButtons.ButtonOneFlagPath}" Stretch="Uniform" Margin="5" />
                        <Viewbox Stretch="Uniform" Grid.Column="1">
                            <TextBlock TextWrapping="Wrap" Style="{DynamicResource BigTextBlockPlusMatic}">
                                <TextBlock.Inlines>
                                    <Run Text="{DynamicResource 103ita}" />
                                    <LineBreak />
                                    <Run Text="{DynamicResource 103eng}" />
                                    <LineBreak />
                                    <Run Text="{DynamicResource 103fra}" />
                                    <LineBreak />
                                    <Run Text="{DynamicResource 103deu}" />
                                    <LineBreak />
                                    <Run Text="{DynamicResource 103esp}" />
                                </TextBlock.Inlines>
                            </TextBlock>
                        </Viewbox>
                    </Grid>
                </Border>
            </ControlTemplate>
    
            <ControlTemplate x:Key="ButtonOnePictureAndTextControlTemplate" TargetType="{x:Type Control}">
                <Border>
                    <Grid >
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <Image Grid.Column="0" Source="{Binding Source={StaticResource Locator}, Path=FrontendButtons.ButtonOnePicturePath}" Stretch="Uniform" Margin="5" />
                        <Viewbox Stretch="Uniform" Grid.Column="1">
                            <TextBlock TextWrapping="Wrap" Style="{DynamicResource BigTextBlockPlusMatic}">
                                <TextBlock.Inlines>
                                    <Run Text="{Binding Source={StaticResource Locator}, Path=FrontendButtons.ButtonOneTextToShow}" />
                                </TextBlock.Inlines>
                            </TextBlock>
                        </Viewbox>
                    </Grid>
                </Border>
            </ControlTemplate>
    
            <DataTemplate x:Key="ButtonOneDataTemplate">
                <Control x:Name="theControl" Template="{DynamicResource ButtonOneLangChangeControlTemplate}" />
                <DataTemplate.Triggers>
                    <DataTrigger Binding="{Binding Path=UseButtonOneLangChangeControlTemplate}" Value="true">
                        <Setter TargetName="theControl" Property="Template" Value="{DynamicResource ButtonOneLangChangeControlTemplate}" />
                    </DataTrigger>
                    <DataTrigger Binding="{Binding Path=UseButtonOneLangChangeControlTemplate}" Value="false">
                        <Setter TargetName="theControl" Property="Template" Value="{DynamicResource ButtonOnePictureAndTextControlTemplate}" />
                    </DataTrigger>
                </DataTemplate.Triggers>
            </DataTemplate>
    
        </Grid.Resources>
        <Grid.RowDefinitions>
            <RowDefinition Height="0.25*"/>
            <RowDefinition Height="0.25*"/>
            <RowDefinition Height="0.25*"/>
            <RowDefinition Height="0.25*"/>
        </Grid.RowDefinitions>
        <Button x:Name="ButtonOne" Margin="0,5,10,5" ContentTemplate="{StaticResource ButtonOneDataTemplate}" Grid.Row="0" Style="{DynamicResource FrontendButtonStyle}" />
    </Grid>
    

    By simply binding the boolean property “UseButtonOneLangChangeControlTemplate” in the dataTrigger from ViewModel I can change runtime the data template.

    L

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

Sidebar

Related Questions

I have an application with a tab bar controller and each view contains a
I have one (razor) page that contain 5 different partial views. Each partial view
I have several elements that are needed in each view and trying to set
I have an application where for each object the user can specify his own
I have created an UITabView application. Each view selected from the bar is a
I have developed a few applications now all using single view controllers. In each
I have 3 views in my application. My first view (FIRST_VIEW) has 2 buttons
I am creating view models for each screen in my ASP.NET MVC application. I
I developed one swing application but each time you run application new window is
I have various objects in application,and each has isvalid method to test if values

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.