Simultaneous use of ContentTemplate and Content results in an error #3197
-
Good afternoon! <DataTemplate x:Key="Style2">
<Grid>
<ContentPresenter/>
<!-- Other elements -->
</Grid>
</DataTemplate>
<Style x:Key="Style1" TargetType="{x:Type md:ColorZone}">
<Setter Property="ContentTemplate" Value="{StaticResource Style2}"/>
<Setter Property="Content">
<Setter.Value>
<md:PackIcon Kind="SortDescending"/>
</Setter.Value>
</Setter>
</Style> Any ideas? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
@Frillaut It would seem you're mixing concepts in an unfortunate combination here. Often times when the In your case, <DataTemplate x:Key="Style2">
<Grid>
<md:PackIcon Kind="SortDescending"/>
<!-- Other elements -->
</Grid>
</DataTemplate>
<Style x:Key="Style1" TargetType="{x:Type md:ColorZone}">
<Setter Property="ContentTemplate" Value="{StaticResource Style2}"/>
</Style> Or you can omit the <Style x:Key="Style1" TargetType="{x:Type md:ColorZone}">
<Setter Property="Content">
<Setter.Value>
<Grid>
<md:PackIcon Kind="SortDescending"/>
<!-- Other elements -->
</Grid>
</Setter.Value>
</Setter>
</Style> My gut feeling tells me that it is the With that said, the code you provided does seem a little odd to me. It may be easier to provide valuable feedback if you could add a bit more context. |
Beta Was this translation helpful? Give feedback.
@Frillaut I see. For such a scenario, I think I would create an attached property to hold the
PackIconKind
. You can then set that attached property value directly in the StyleNavigationComboBoxFilter1/StyleNavigationComboBoxFilter2 styles in a manner like this:And then in your ContentTemplateNavigationComboBox
DataTemplate
you could use that instead of theC…