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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. WPF
  4. Cannot find governing FrameworkElement or FrameworkContentElement

Cannot find governing FrameworkElement or FrameworkContentElement

Scheduled Pinned Locked Moved WPF
wpfcsharpcssdotnetwcf
1 Posts 1 Posters 0 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.
  • S Offline
    S Offline
    stofel
    wrote on last edited by
    #1

    Hi, I'm a newbie in wpf and I have a problem with the binding. I have a class inherited from FramworkElement and there is a Collection. The Items of this collection are inherited from DependencyObject. On the Form is only one TextBox. I want that the text, which is typed by the user will be copied into the first Item of the collection. Here some code

    public class Item: DependencyObject
    {
    public string Name { get; set; }

          public virtual object Value {
            get { return GetValue(ValueProperty); }
            set { SetValue(ValueProperty, value); }
        }
    
        #region DependenvyProperty
          public static readonly DependencyProperty ValueProperty =
              DependencyProperty.Register("Value", typeof(object), typeof(Item));
        #endregion
    
    }
    
    public class ItemContainer : FrameworkElement
    {
       
        private List<Item> \_itemlist = new List<Item>();
    
        public List<Item> ItemList
        {
            get { return \_itemlist; }
        }
    }
    

    and the form:

    Window x:Class="WpfApplication2.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="417" Width="589" xmlns:my="clr-namespace:WpfApplication2">
    <Grid>
    <my:ItemContainer Height="18" HorizontalAlignment="Left" Margin="-168,0,0,33" x:Name="itemContainer1" VerticalAlignment="Bottom" Width="18">
    my:ItemContainer.ItemList
    <my:Item Name="Item1" Value="{Binding ElementName=txtItem1, Path=Text}" />
    <my:Item Name="Item2" />
    </my:ItemContainer.ItemList>
    </my:ItemContainer>
    <Canvas Margin="16,18,8,6" Name="canvas1">
    <TextBox Canvas.Left="88" Canvas.Top="15" Height="23" Name="txtitem1" Width="89" />
    <Label Canvas.Left="14" Canvas.Top="16" Height="22" Name="label1" Width="58">Item1
    </Label>
    </Canvas>
    </Grid>
    </Window>

    At runtime the program displays the error2 Cannot find governing FrameworkElement or FrameworkContentElement. I don't want to inherit item from FrameworkelElement because in the real project the class Item is inherited from another class. What can I do to transfer the text from the textbox to the first item of the collection ? Thanks in Advance

    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