Click here to Skip to main content
13,868,633 members

Silverlight / WPF

 
GeneralRe: MVVM Tasks and UI Updating Pin
cjb11025-Mar-13 2:56
membercjb11025-Mar-13 2:56 
GeneralRe: MVVM Tasks and UI Updating Pin
cjb11025-Mar-13 5:45
membercjb11025-Mar-13 5:45 
AnswerRe: MVVM Tasks and UI Updating Pin
Abhinav S25-Mar-13 8:26
memberAbhinav S25-Mar-13 8:26 
GeneralRe: MVVM Tasks and UI Updating Pin
cjb11025-Mar-13 8:36
membercjb11025-Mar-13 8:36 
QuestionProblems on ListView Control in WPF Pin
bikah chanda mohanta21-Mar-13 3:56
memberbikah chanda mohanta21-Mar-13 3:56 
AnswerRe: Problems on ListView Control in WPF Pin
Kenneth Haugland22-Mar-13 3:03
professionalKenneth Haugland22-Mar-13 3:03 
QuestionRoute Event for Button border Pin
Member 878633518-Mar-13 21:50
memberMember 878633518-Mar-13 21:50 
QuestionWPF treeview with circular reference not updating the childTreeviewItem Pin
geetha naidu17-Mar-13 1:39
membergeetha naidu17-Mar-13 1:39 
Hi All, i am attaching my class design and the xaml code which i am using to create a treeview item with circular reference. I am able to update the collecitons from the codebehind but unfortuntely it is not reflecting in the code behind. Please help me in esolving this

public class EntityDesignElement : NotifyPropertyChangedBase
   {
       private string _id;
       private ObservableCollection<EntityDesignElement> _children = new ObservableCollection<EntityDesignElement>();

       private ObservableCollection<WrapperMetadataExtension> _extensions = new ObservableCollection<WrapperMetadataExtension>();

       public ObservableCollection<WrapperMetadataExtension> Extensions
       {
           get { return _extensions; }
           set
           {
               _extensions = value;

           }
       }

       protected EntityDesignElement(EntityDesignElement parent)
       {
           Parent = parent;
           _children.CollectionChanged += delegate(object sender, NotifyCollectionChangedEventArgs args) { OnPropertyChanged("HasChildren"); };
           _children.CollectionChanged += delegate(object sender, NotifyCollectionChangedEventArgs args) { OnPropertyChanged("IsExtensionAddedToChildren"); };
           //if (_children != null)
           //    _children.CollectionChanged += delegate(object sender, NotifyCollectionChangedEventArgs args) { OnPropertyChanged("Extensions"); };
           _extensions.CollectionChanged += delegate(object sender, NotifyCollectionChangedEventArgs args) { OnPropertyChanged("IsExtensionAddedToChildren"); };
       }

       public EntityDesignElement(EntityDesignElement parent, EntityInfo info)
           : this(parent)
       {
           Name = info.Name;
           Type = info.Id;
           ElementType = "Entity";
           IsChildrenAllowed = true;

           foreach (var property in info.Properties)
           {
               Children.Add(new EntityDesignElement(this, property));
           }
       }

       public EntityDesignElement(EntityDesignElement parent, EntityPropertyInfo propertyInfo)
           : this(parent)
       {
           Name = propertyInfo.Name;
           ElementType = "Property";
           Type = propertyInfo.DataType;
           IsChildrenAllowed = (((propertyInfo.PropertyType == EntityPropertyType.Reference)
               || (propertyInfo.PropertyType == EntityPropertyType.ReferenceCollection))
               && (!IsCircularReference(Type)));

           if (IsChildrenAllowed)
           {
               var entity = ClientConnector.Current.Metadata.GetEntity(propertyInfo.DataType);
               if (entity != null)
                   foreach (var property in entity.Properties)
                   {
                       EntityDesignElement child = new EntityDesignElement(this, property);
                       //child._children.CollectionChanged += delegate(object sender, NotifyCollectionChangedEventArgs args) { OnPropertyChanged("HasChildren"); };
                       //child._extensions.CollectionChanged += delegate(object sender, NotifyCollectionChangedEventArgs args) { OnPropertyChanged("Extensions"); };
                       Children.Add(child);
                   }
           }

       }

       public void AddExtension(EntityDesignElement parent, WrapperMetadataExtension extension)
       {
           Parent.Extensions.Add(extension);
       }

       public EntityDesignElement Parent { get; private set; }

       public string Name
       {
           get { return _id; }
           set { SetAndNotifyPropertyChanged<string>("Id", ref _id, value); }
       }

       public string ElementType { get; private set; }

       public string Type { get; private set; }
       public bool IsChildrenAllowed { get; private set; }
       public bool HasChildren { get { return (_children.Count > 0); } }

       //private bool _isExtensionAddedToChildren;
       public bool IsExtensionAddedToChildren {
           get { return (Parent.Extensions.Count>0); }
           //set { _isExtensionAddedToChildren= value; }
       }


       public ObservableCollection<EntityDesignElement> Children { get { return _children; } }

       private bool IsCircularReference(string type)
       {
           if (Parent == null)
               return false;
           if (Parent.Type.Equals(type))
               return true;
           return Parent.IsCircularReference(type);
       }


       public ObservableCollection<MetadataExtension> GetMetadataExtensions()
       {
           ObservableCollection<MetadataExtension> colls = new ObservableCollection<MetadataExtension>();
           //foreach (WrapperMetadataExtensionCollectionCollection item in Extensions)
           //{
           //    colls.Add(new MetadataExtension
           //        {
           //            ExtensionType=item.ExtensionType,
           //            Property=item.ExtensionType,
           //            Parameters=item.GetParameters()
           //        });
           //}
           return colls;
       }
   }

<UserControl x:Class="CeniumDesignTool.Controls.Designer.MetadataEntityControl"

             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 

             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 

             xmlns:Utitlity="clr-namespace:CeniumDesignTool.Utilities"

              xmlns:metadata="clr-namespace:Cenium.Framework.Client.Application.ResourceModel.Metadata;assembly=Cenium.Framework.Client.Resources"

             mc:Ignorable="d" x:Name="MetadataEntityControlRoot"

             d:DesignHeight="300" d:DesignWidth="300">
    <Grid x:Name="LayoutRoot" DataContext="{Binding ElementName=MetadataEntityControlRoot}">
        <Grid.Resources>
            <Utitlity:ExtensionConverter x:Key="extConverter"/>
            <Style TargetType="TextBlock" x:Key="txtEntityInfoStyle">
                <Setter Property="FontWeight" Value="Bold" />
                <Setter Property="HorizontalAlignment" Value="Center"/>
                <Setter Property="VerticalAlignment" Value="Center"/>
            </Style>
            <Utitlity:MetadataTemplateSeletor x:Key="TempSelector"/>
            <BitmapImage x:Key="imgLock" UriSource="pack://application:,,,/Resources/Images/lock.png" />
            <BitmapImage x:Key="imgExtension" UriSource="pack://application:,,,/Resources/Images/extension.png" />
            <HierarchicalDataTemplate x:Key="MetadataEntityParentTemplate" ItemTemplateSelector="{StaticResource ResourceKey=TempSelector}">
                <!-- bind the different data sources -->
                <HierarchicalDataTemplate.ItemsSource>

                    <MultiBinding Converter="{StaticResource extConverter}">
                        <Binding Path="Children" UpdateSourceTrigger="PropertyChanged"/>
                        <Binding Path="Extensions" UpdateSourceTrigger="PropertyChanged"/>

                    </MultiBinding>
                </HierarchicalDataTemplate.ItemsSource>
                <Border BorderBrush="Black" Margin="2,2,2,2" BorderThickness="1" CornerRadius="17" Background="Gray" Padding="0,0,5,0">
                    <Grid Width="Auto" MinWidth="200">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition />
                        </Grid.RowDefinitions>
                        <TextBlock Grid.Column="1" Text="{Binding Type}" 

					Margin="0" HorizontalAlignment="Center" VerticalAlignment="Center" Style="{StaticResource txtEntityInfoStyle}" />
                        <Rectangle Grid.Column="2" Height="20" Width="20" Margin="5" Stroke="Black" HorizontalAlignment="Right" VerticalAlignment="Center">
                            <Rectangle.Fill>
                                <ImageBrush ImageSource="{StaticResource imgLock}"/>
                            </Rectangle.Fill>
                        </Rectangle>
                    </Grid>
                </Border>
            </HierarchicalDataTemplate>
            <HierarchicalDataTemplate x:Key="MeatadataEntityExtensions" ItemsSource="{Binding Path=Parameters}">
                <!--ItemsSource= "{Binding Path=Parameters}"-->
                <Grid Width="250">
                    <Border BorderBrush="Black" BorderThickness="1" CornerRadius="17" Margin="2,2,2,2" Padding="0,0,5,0" Background="LightGreen">
                        <StackPanel Width="auto" MinWidth="200" Orientation="Horizontal">
                            <TextBlock Margin="5" Text="{Binding ExtensionType, UpdateSourceTrigger=PropertyChanged}"  VerticalAlignment="Center" Style="{StaticResource txtEntityInfoStyle}" ></TextBlock>

                            <TextBlock Margin="5" Text="{Binding Property}"  VerticalAlignment="Center" Grid.Column="1" Style="{StaticResource txtEntityInfoStyle}" ></TextBlock>

                            <Rectangle Height="20" Width="20" Margin="5" Stroke="Black" HorizontalAlignment="Right">
                                <Rectangle.Fill>
                                    <ImageBrush ImageSource="{StaticResource imgExtension}"/>
                                </Rectangle.Fill>
                            </Rectangle>
                        </StackPanel>
                    </Border>
                </Grid>
                <!--<HierarchicalDataTemplate.ItemTemplate>
                    <HierarchicalDataTemplate >
                        <Border BorderBrush="Black" BorderThickness="1" CornerRadius="17" Margin="2,2,2,2"  Padding="0,0,5,0" Background="LightGreen">
                            <StackPanel Width="auto" MinWidth="250" Orientation="Horizontal">
                                <TextBlock Margin="5" Text="{Binding ExtensionType}"  VerticalAlignment="Center" Style="{StaticResource txtEntityInfoStyle}" ></TextBlock>
                                <TextBlock Margin="5" Text="{Binding Value}"  Style="{StaticResource txtEntityInfoStyle}" ></TextBlock>
                                <TextBlock Margin="5" Text=" : " Style="{StaticResource txtEntityInfoStyle}" />
                                <TextBlock Margin="5" Text="{Binding ValueType}" Style="{StaticResource txtEntityInfoStyle}" />
                                <Rectangle Height="20" Width="20" Margin="5" Stroke="Black" HorizontalAlignment="Right">
                                    <Rectangle.Fill>
                                        <ImageBrush ImageSource="{StaticResource imgExtension}"/>
                                    </Rectangle.Fill>
                                </Rectangle>
                            </StackPanel>
                        </Border>
                    </HierarchicalDataTemplate>
                </HierarchicalDataTemplate.ItemTemplate>-->
            </HierarchicalDataTemplate>

            <DataTemplate x:Key="MeatadataEntityProperties">

                <Border BorderBrush="Black" BorderThickness="1" CornerRadius="17"  Padding="0,0,0,0" Background="Gray" Margin="2,2,2,2">
                    <!--<StackPanel Width="200" Orientation="Horizontal">
                     
                       
                <TextBlock Margin="5" Text="{Binding Value}" ></TextBlock>
                <TextBlock Margin="5" Text=" : "/>
                <TextBlock Margin="5" Text="{Binding ValueType}"/>
                    <Rectangle Height="20" Width="20" Margin="5" Stroke="Black" HorizontalAlignment="Right">
                        <Rectangle.Fill>
                            <ImageBrush ImageSource="lock.png"/>
                        </Rectangle.Fill>
                    </Rectangle>
                </StackPanel>-->
                    <Grid Width="auto" MinWidth="200" HorizontalAlignment="Center" VerticalAlignment="Center">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition />
                        </Grid.RowDefinitions>
                        <TextBlock Grid.Column="0" Margin="20,0,0,0" Text="{Binding Name}" Style="{StaticResource txtEntityInfoStyle}"></TextBlock>
                        <TextBlock Grid.Column="1" Margin="0" Text=" : " Style="{StaticResource txtEntityInfoStyle}"/>
                        <TextBlock Grid.Column="2" Margin="0" Text="{Binding PropertyType}" Style="{StaticResource txtEntityInfoStyle}"/>
                        <TextBlock Grid.Column="3" Margin="0" Text=" ( " Style="{StaticResource txtEntityInfoStyle}"/>
                        <TextBlock Grid.Column="4" Margin="0" Text="{Binding Reference}" Style="{StaticResource txtEntityInfoStyle}"/>
                        <TextBlock Grid.Column="5" Margin="0" Text=" ) " Style="{StaticResource txtEntityInfoStyle}"/>
                        <Rectangle Grid.Column="6" Height="20" Width="20" Margin="5" Stroke="Black" HorizontalAlignment="Right">
                            <Rectangle.Fill>
                                <ImageBrush ImageSource="{StaticResource imgLock}"/>
                            </Rectangle.Fill>
                        </Rectangle>
                    </Grid>
                </Border>
            </DataTemplate>
            
            <HierarchicalDataTemplate x:Key="ClassReferenceMetadataEntity" ItemsSource="{Binding Path=Children}">
                <Border BorderBrush="Black" Margin="2,2,2,2" BorderThickness="1" CornerRadius="17" Background="Gray" Padding="0,0,0,0">
                    <Grid Width="Auto" MinWidth="200">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition />
                        </Grid.RowDefinitions>
                        <Grid Grid.Column="1">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition/>
                                <ColumnDefinition/>
                                <ColumnDefinition/>
                            </Grid.ColumnDefinitions>
                            <TextBlock  Text="{Binding Name}" Grid.Column="0"

					Margin="0" HorizontalAlignment="Center" VerticalAlignment="Center" Style="{StaticResource txtEntityInfoStyle}" />
                            <TextBlock  Text=":"  Grid.Column="1"

					Margin="0" HorizontalAlignment="Center" VerticalAlignment="Center" Style="{StaticResource txtEntityInfoStyle}" />
                            <TextBlock  Text="{Binding Type}"  Grid.Column="2"

					Margin="0" HorizontalAlignment="Center" VerticalAlignment="Center" Style="{StaticResource txtEntityInfoStyle}" />
                        </Grid>
                        
                        <Rectangle Grid.Column="2" Height="20" Width="20" Margin="5" Stroke="Black" HorizontalAlignment="Right" VerticalAlignment="Center">
                            <Rectangle.Fill>
                                <ImageBrush ImageSource="{StaticResource imgLock}"/>
                            </Rectangle.Fill>
                        </Rectangle>
                    </Grid>
                </Border>
            </HierarchicalDataTemplate>
        </Grid.Resources>
        <TreeView x:Name="ListViewExtensionTypesDesign" AllowDrop="True" Width="auto" Height="auto" ItemsSource="{Binding}" ItemTemplate="{StaticResource MetadataEntityParentTemplate}" TreeViewItem.Selected="ListViewExtensionTypesDesign_Selected">
            <!--<TreeView.ItemContainerStyle>
                <Style TargetType="{x:Type TreeViewItem}">
                    <EventSetter Event="TreeViewItem.DragOver"  Handler="treeView_DragOver"/>
                    <EventSetter Event="TreeViewItem.Drop" Handler="treeView_Drop"/>
                    <EventSetter Event="TreeViewItem.MouseMove" Handler="treeView_MouseMove"/>
                    <EventSetter Event="TreeViewItem.MouseDown" Handler="treeView_MouseDown"/>
                </Style>
            </TreeView.ItemContainerStyle>-->
        </TreeView>

        <!--TreeViewItem.Selected="ListViewExtensionTypesDesign_Selected" ItemTemplate="{StaticResource MetadataEntityParentTemplate}"  ItemContainerStyle="{DynamicResource TreeViewItemStyle1}" BorderBrush="{x:Null}" BorderThickness="0" Style="{DynamicResource TreeViewStyle1}"-->
    </Grid>
</UserControl>

Geetha

QuestionStack panel Pin
columbos1492715-Mar-13 10:35
membercolumbos1492715-Mar-13 10:35 
AnswerRe: Stack panel Pin
Gerry Schmitz15-Mar-13 12:01
mveGerry Schmitz15-Mar-13 12:01 
AnswerRe: Stack panel Pin
Mycroft Holmes15-Mar-13 14:30
memberMycroft Holmes15-Mar-13 14:30 
QuestionHow to add multiple button into same datacell in DataGrid column Pin
Jayantha Bandara15-Mar-13 1:45
memberJayantha Bandara15-Mar-13 1:45 
AnswerRe: How to add multiple button into same datacell in DataGrid column Pin
Pete O'Hanlon15-Mar-13 2:14
protectorPete O'Hanlon15-Mar-13 2:14 
AnswerRe: How to add multiple button into same datacell in DataGrid column Pin
Jayantha Bandara15-Mar-13 2:41
memberJayantha Bandara15-Mar-13 2:41 
GeneralRe: How to add multiple button into same datacell in DataGrid column Pin
Mycroft Holmes15-Mar-13 14:26
memberMycroft Holmes15-Mar-13 14:26 
QuestionLoading XAML at runtime Pin
Jayme6514-Mar-13 9:11
memberJayme6514-Mar-13 9:11 
AnswerRe: Loading XAML at runtime Pin
marimuthu2620-Mar-13 4:54
membermarimuthu2620-Mar-13 4:54 
QuestionWPF First Start Performance Pin
savbace14-Mar-13 3:16
membersavbace14-Mar-13 3:16 
AnswerRe: WPF First Start Performance Pin
Richard MacCutchan14-Mar-13 4:04
protectorRichard MacCutchan14-Mar-13 4:04 
QuestionWPF MVVM application Pin
Member 878633514-Mar-13 2:49
memberMember 878633514-Mar-13 2:49 
AnswerRe: WPF MVVM application Pin
NotPolitcallyCorrect14-Mar-13 3:50
memberNotPolitcallyCorrect14-Mar-13 3:50 
AnswerRe: WPF MVVM application Pin
Wayne Gaylard14-Mar-13 8:53
mentorWayne Gaylard14-Mar-13 8:53 
AnswerRe: WPF MVVM application Pin
Abhinav S18-Mar-13 8:09
memberAbhinav S18-Mar-13 8:09 
AnswerRe: WPF MVVM application Pin
_Maxxx_1-Apr-13 20:52
professional_Maxxx_1-Apr-13 20:52 
Questionsilverlight file upload, error not displays on browser Pin
vpraveen12-Mar-13 22:30
membervpraveen12-Mar-13 22:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Cookies | Terms of Service
Web01 | 2.8.190214.1 | Last Updated 14 Feb 2019
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid