Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. Custom UserControl question.... [modified]

Custom UserControl question.... [modified]

Scheduled Pinned Locked Moved WPF
questionwpfhelp
3 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Phil Boyd
    wrote on last edited by
    #1

    I have the following custom UserControl: <Setter Property="MinWidth" Value="55" /> <Setter Property="MaxWidth" Value="60" /> <Setter Property="Margin" Value="0,0,5,0" /> Here is the referenced DependencyProperty: public static DependencyProperty UICTypeLabelProperty = DependencyProperty.RegisterAttached("UICTypeLabel", typeof(string), typeof(UICControl), new PropertyMetadata(String.Empty)); public string UICTypeLabel { get { return (string)GetValue(UICTypeLabelProperty); } set { SetValue(UICTypeLabelProperty, value); } } And here is the usage: But I'm not seeing "Responsible" when the control presents itself on the display. What am I doing wrong? I am also seeing this error message in the Output window: System.Windows.Data Error: 39 : BindingExpression path error: 'UICTypeLabel' property not found on 'object' ''BasicViewContext' (HashCode=13769489)'. BindingExpression:Path=UICTypeLabel; DataItem='BasicViewContext' (HashCode=13769489); target element is 'GroupBox' (Name=''); target property is 'Header' (type 'Object') BasicView is the XAML window that is using the control. Thanks Phil -- Modified Thursday, August 26, 2010 3:11 PM

    I 1 Reply Last reply
    0
    • P Phil Boyd

      I have the following custom UserControl: <Setter Property="MinWidth" Value="55" /> <Setter Property="MaxWidth" Value="60" /> <Setter Property="Margin" Value="0,0,5,0" /> Here is the referenced DependencyProperty: public static DependencyProperty UICTypeLabelProperty = DependencyProperty.RegisterAttached("UICTypeLabel", typeof(string), typeof(UICControl), new PropertyMetadata(String.Empty)); public string UICTypeLabel { get { return (string)GetValue(UICTypeLabelProperty); } set { SetValue(UICTypeLabelProperty, value); } } And here is the usage: But I'm not seeing "Responsible" when the control presents itself on the display. What am I doing wrong? I am also seeing this error message in the Output window: System.Windows.Data Error: 39 : BindingExpression path error: 'UICTypeLabel' property not found on 'object' ''BasicViewContext' (HashCode=13769489)'. BindingExpression:Path=UICTypeLabel; DataItem='BasicViewContext' (HashCode=13769489); target element is 'GroupBox' (Name=''); target property is 'Header' (type 'Object') BasicView is the XAML window that is using the control. Thanks Phil -- Modified Thursday, August 26, 2010 3:11 PM

      I Offline
      I Offline
      Ian Shlasko
      wrote on last edited by
      #2

      Because the GroupBox is looking for "UICTypeLabel" on its DataContext, not on the UserControl. You need to tell it where to look. Header="{Binding UICTypeLabel,RelativeSource={RelativeSource FindAncestor,AncestorType=UserControl}}" (Might have to use {x:Type UserControl} in there... I forget whether it's necessary)

      Proud to have finally moved to the A-Ark. Which one are you in?
      Author of the Guardians Saga (Sci-Fi/Fantasy novels)

      P 1 Reply Last reply
      0
      • I Ian Shlasko

        Because the GroupBox is looking for "UICTypeLabel" on its DataContext, not on the UserControl. You need to tell it where to look. Header="{Binding UICTypeLabel,RelativeSource={RelativeSource FindAncestor,AncestorType=UserControl}}" (Might have to use {x:Type UserControl} in there... I forget whether it's necessary)

        Proud to have finally moved to the A-Ark. Which one are you in?
        Author of the Guardians Saga (Sci-Fi/Fantasy novels)

        P Offline
        P Offline
        Phil Boyd
        wrote on last edited by
        #3

        Oh man - you are awesome!!!! Phil

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups