wpf - Nested ContentControls with template -


I have a custom window style , XAM looks like this: < Pre> & lt; Style TargetType = "{x: type window}" x: Key = "WindowStyle" & gt; / ** Some Sets ** / & lt; Setter Estates = "Template" & gt; & Lt; Setter.Value & gt; & Lt; ControlTemplate TargetType = "Content Control" & gt; & Lt; AdornerDecorator & gt; & Lt; Grid Background = "# 88000000" X: Name = "Windbikgram Grid" & gt; & Lt; Border x: name = "WindowContentBorder" background = "{DynamicResource WindowBackground}" maxHeight = "{binding source = {x: static SystemParameters.FullPrimaryScreenHeight}}" MaxWidth = "{binding source = {x: static SystemParameters.FullPrimaryScreenWidth}}" Margin = "20" & gt; & Lt; Grid & gt; & Lt; Grid.RowDefinitions & gt; & Lt; RowDefinition Height = "Auto" /> & Lt; Roadfinion height = "*" /> & Lt; /Grid.RowDefinitions> & Lt ;! - Header - & gt; & Lt; Border border brush = "{DynamicResource BorderBrushColor}" background = "{DynamicResource PaneHeader_Background}" grid. Line = "0" & ​​gt; & Lt; TextBlock Text = "Title" Foreground = "{DynamicResource DefaultForeground}" FontSism = "16" fontEight = "bold" margin = "5,5,2,5" /> & lt; / Border & gt; & Lt ;! - content - & gt; & Lt; ScrollViewer Grid Line = "1" margin = "5" & gt; & Lt; Content display content = "{TemplateBinding content}" /> & Lt; / ScrollViewer & gt; & Lt; / Grid & gt; & Lt; / Border & gt; & Lt; / Grid & gt; & Lt; / AdornerDecorator & gt; & Lt; / ControlTemplate & gt; & Lt; /Setter.Value> & Lt; / Setter & gt; & Lt; / Style & gt;

Now I want the inner grid in a different style so that I can use it somewhere else.

  & lt; Style x: Key = "WindowContentStyle" TargetType = "{x: Type Content Viewer}" & gt; & Lt; Setter Property = "Content Template" & gt; & Lt; Setter.Value & gt; & Lt; DataTemplate & gt; & Lt; Grid & gt; & Lt; Grid.RowDefinitions & gt; & Lt; RowDefinition Height = "Auto" /> & Lt; Roadfinion height = "*" /> & Lt; /Grid.RowDefinitions> & Lt ;! - Header - & gt; / ** Border Control ** / & lt ;! - content - & gt; & Lt; ScrollViewer Grid Line = "1" margin = "5" & gt; & Lt; Content display content = "{binding content, relative Soros = {relative-values ​​templates pent}}" /> & Lt; / ScrollViewer & gt; & Lt; / Grid & gt; & Lt; / DataTemplate & gt; & Lt; /Setter.Value> & Lt; / Setter & gt; & Lt; / Style & gt;   

and I use a to present my WindowStyle in ContenPresenter :

  & Lt; ContentPresenter & gt; & Lt; ContentPresenter.Style & gt; & Lt; Style TargetType = "{x: type content view}" based on = "{static resource window content system}" /> & Lt; /ContentPresenter.Style> & Lt; / ContentPresenter & gt;   Problem   

The above edit did not give me any errors, but this is my WindowContentStyle . When I control content to the window and loads the style

  this.window.Content = view; This.window.Style = (style) application. Current.TryFindResource ("WindowStyle");   

The content is shown in WindowStyle in ContentPresenter and is not in WindowContentStyle . Due to this, template is not used and I do not have a title heading.

How do I pass my external ContentPresenter on my content my internal ContentPresenter (a WindowContentStyle in)

Thanks in advance!

Greetings Leyton

To display your content, ContentControl should be used, not a ContentPresenter . From the page on MSDN:

You typically use ContentPresenter ControlTemplate in a ContentControl P> > is a limited default style if you want to increase the look of the control, you can create a new DataTemplate

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -