N
N
Necronel2015-07-17 10:00:51
Windows phone
Necronel, 2015-07-17 10:00:51

Problem with UserControl, how to delimit content sheets?

There is a UserControl that provides content change.
The control's markup is a ContentPresenter that receives information from a ContentList:

#region Contentlist
public static readonly DependencyProperty ContentListProperty =
            DependencyProperty.Register("ContentList", typeof(List<UIElement>), typeof(DynamicContentViewer), new PropertyMetadata(new List<UIElement>()));

public List<UIElement> ContentList
{
      get 
      { 
            return (List<UIElement>)this.GetValue(ContentListProperty); 
      }
      set
      {
            this.SetValue(ContentListProperty, value);
      }
}
#endregion

In the markup, two controls with different names are declared, in each of the controls in the body a ContentList is defined:
<customs:DynamicContentViewer x:Name="LeftPanelViewer"
Loaded="LeftPanelViewer_Loaded"
NavigateMode="0">
<customs:DynamicContentViewer.ContentList>
<TextBlock />
<TextBlock />
</customs:DynamicContentViewer.ContentList>
</customs:DynamicContentViewer>

<customs:DynamicContentViewer x:Name="MainPanelViewer"
Loaded="MainPanelViewer_Loaded"
NavigateMode="0">
<customs:DynamicContentViewer.ContentList>
<TextBox />
<TextBox />
</customs:DynamicContentViewer.ContentList>
</customs:DynamicContentViewer>

When viewing the content in each of the controls in the ContentList 4 elements are lying around. Those. all elements fall into the ContentList regardless of the object in whose body the parameter was defined. How to distinguish them?
Those. in LeftPanelViewer - ContenList: TextBlock, TextBlock, TextBox, TextBox
in MainPanelViewer - ContenList: TextBlock, TextBlock, TextBox, TextBox

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Necronel, 2015-07-17
@Necronel

Found a solution, DependencyProperty if it is static, then it does not come from an object of a certain class. If you leave public readonly DependencyProperty ContentListProperty, then everything is fine.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question