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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:11:10+00:00 2026-05-31T13:11:10+00:00

I have this XML file: <?xml version=1.0 encoding=utf-8?> <Wpf> <wpfctrl id=NavBtnTemplate>#FFCFDEFF</wpfctrl> </Wpf> and i

  • 0

I have this XML file:

<?xml version="1.0" encoding="utf-8"?>
<Wpf>
  <wpfctrl id="NavBtnTemplate">#FFCFDEFF</wpfctrl>
</Wpf>

and i want to bind Fill property of My Rectangle to value of wpfctrl node with id=”NavBtnTemplate”. How I can achieve this? Actually I have this rectangle inside my custom UserControl’s Control Template. But hope that will not be the problem since I can bind to the properties of elements inside UserControl:
My UserControl (actually is very simple)

<UserControl.Resources>
  <ControlTemplate x:Key="WpfWebSparkNavTemplate" TargetType="{x:Type Button}">
    <Grid x:Name="controlLayout" Height="29.648" Width="84.284">
    <VisualStateManager.VisualStateGroups>
      <VisualStateGroup x:Name="CommonStates">
        <VisualState x:Name="Normal"/>
        <VisualState x:Name="MouseOver"/>
        <VisualState x:Name="Pressed"/>
        <VisualState x:Name="Disabled"/>
      </VisualStateGroup>
    </VisualStateManager.VisualStateGroups>
    <Rectangle x:Name="rectangle"***Fill="#FFCFDEFF"*** Margin="0" Height="31">           
    </Rectangle>
  <Label x:Name="buttonCaption" VerticalAlignment = "Center"
     HorizontalAlignment = "Center"
     FontWeight = "Bold" FontSize = "12" Content="{TemplateBinding Content}"/>
  </Grid>
 </ControlTemplate>
</UserControl.Resources>

I did not found Blend wizard to allow me to state such filters on XML

Please help. Thank you.

  • 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-31T13:11:11+00:00Added an answer on May 31, 2026 at 1:11 pm

    If I understand correctly, you want to bind the Fill Property of the Rectangle within your UserControl to a property which you set (or bind) when declaring the instance of the UserControl in XAML.

    The first thing that you want to do is have a Fill Property on your user control, so create a DependencyProperty in the UserControl’s code behind:

    public static readonly DependencyProperty FillProperty = 
        DependencyProperty.Register(
            "Fill", 
            typeof(Brush),
            typeof(UserControl1));
    
    public Brush Fill
    {
        get { return (Brush)GetValue(FillProperty); } 
        set { SetValue(FillProperty, value); }
    } 
    

    With this in place, you can modify the ControlTemplate so that rectangle Fill property binds to this DependencyProperty (change the WpfApplication1 namespace appropriately):

    <Rectangle x:Name="rectangle" Fill="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=WpfApplication1:UserControl1}, Path=Fill}" Margin="0" Height="31"/>
    

    Then you can use your control as follows:

    <WpfApplication1:UserControl1 Grid.Row="1" Fill="Red"/>
    

    The next thing to do is to bind the UserControl’s Fill property. You need to create a data source to your XML file, e.g.:

    <Window.Resources>
        <XmlDataProvider x:Key="xmlData" Source="XMLFile1.xml"/>
    </Window.Resources>
    

    And then bind to the datasource:

        <WpfApplication1:UserControl1 Grid.Row="0">
            <WpfApplication1:UserControl1.Fill>
                <Binding Source="{StaticResource xmlData}"
                         XPath="//wpfctrl[@id='NavBtnTemplate']"/>
            </WpfApplication1:UserControl1.Fill>
        </WpfApplication1:UserControl1>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this xml file <?xml version=1.0 encoding=UTF-8?> <bo:C837ClaimParent xsi:type=bo:C837ClaimParent xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xmlns:bo=http://somelongpathHere/process/bo> <claimAux> ...
I have this data from a xml file: <?xml version=1.0 encoding=utf-8 ?> <words> <id>...</id>
I have an XML file looks like this: <?xml version=1.0 encoding=utf-8 ?> <PathMasks> <Mask
have an xml file like this. <?xml version =1.0 encoding =utf-8?> <menu> <menuNode title=Register
I have an xml file which looks like this <?xml version=1.0 encoding=UTF-8 ?> <BulkDataExchangeRequests
I have an options_menu.xml file like this: <?xml version=1.0 encoding=utf-8?> <menu xmlns:android=http://schemas.android.com/apk/res/android> <item android:id=@+id/search
I have a simple XML file like so: <?xml version=1.0 encoding=UTF-8?> <foo attr=blah &#176;
An example XML file is this: <?xml version=1.0 encoding=UTF-8?> <game> <name>bomber</name> <behaviors-used> <behavior id=Bullet
Here's an example of an XML file created in InfoPath: <?xml version=1.0 encoding=UTF-8?> <?mso-infoPathSolution
Say I have this given XML file: <root> <node>x</node> <node>y</node> <node>a</node> </root> And I

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.