none
[UWP]“TemplateBinding' used after '{' must be a Markup Extension” Error on UWP GridView RRS feed

  • Question

  • Hi,

    I have a GridView on my MainPage.xaml. I wanted the change outermost border brush color in GeneratedItemContainerStyle:

    So, I created a new custom style by clicking "Edit a Copy" from GridView/Additional Templates/GeneratedItemContainerStyle.

    Then, this XAML style appeared in my App.xaml.

         <Style x:Key="GridViewItemStyle1" TargetType="GridViewItem">
                <Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}"/>
                <Setter Property="FontSize" Value="{ThemeResource ControlContentThemeFontSize}"/>
                <Setter Property="Background" Value="{ThemeResource GridViewItemBackground}"/>
                <Setter Property="Foreground" Value="{ThemeResource GridViewItemForeground}"/>
                <Setter Property="TabNavigation" Value="Local"/>
                <Setter Property="IsHoldingEnabled" Value="True"/>
                <Setter Property="HorizontalContentAlignment" Value="Center"/>
                <Setter Property="VerticalContentAlignment" Value="Center"/>
                <Setter Property="Margin" Value="0,0,4,4"/>
                <Setter Property="MinWidth" Value="{ThemeResource GridViewItemMinWidth}"/>
                <Setter Property="MinHeight" Value="{ThemeResource GridViewItemMinHeight}"/>
                <Setter Property="AllowDrop" Value="False"/>
                <Setter Property="UseSystemFocusVisuals" Value="True"/>
                <Setter Property="FocusVisualMargin" Value="-2"/>
                <Setter Property="FocusVisualPrimaryBrush" Value="{ThemeResource GridViewItemFocusVisualPrimaryBrush}"/>
                <Setter Property="FocusVisualPrimaryThickness" Value="2"/>
                <Setter Property="FocusVisualSecondaryBrush" Value="{ThemeResource GridViewItemFocusVisualSecondaryBrush}"/>
                <Setter Property="FocusVisualSecondaryThickness" Value="1"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="GridViewItem">
                            <ListViewItemPresenter CheckBrush="{ThemeResource GridViewItemCheckBrush}" ContentMargin="{TemplateBinding Padding}" CheckMode="{ThemeResource GridViewItemCheckMode}" ContentTransitions="{TemplateBinding ContentTransitions}" CheckBoxBrush="{ThemeResource GridViewItemCheckBoxBrush}" DragForeground="{ThemeResource GridViewItemDragForeground}" DragOpacity="{ThemeResource ListViewItemDragThemeOpacity}" DragBackground="{ThemeResource GridViewItemDragBackground}" DisabledOpacity="{ThemeResource ListViewItemDisabledThemeOpacity}" FocusVisualPrimaryBrush="{TemplateBinding FocusVisualPrimaryBrush}" FocusVisualSecondaryThickness="{TemplateBinding FocusVisualSecondaryThickness}" FocusBorderBrush="{ThemeResource GridViewItemFocusBorderBrush}" FocusVisualMargin="{TemplateBinding FocusVisualMargin}" FocusVisualPrimaryThickness="{TemplateBinding FocusVisualPrimaryThickness}" FocusSecondaryBorderBrush="{ThemeResource GridViewItemFocusSecondaryBorderBrush}" FocusVisualSecondaryBrush="{TemplateBinding FocusVisualSecondaryBrush}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Control.IsTemplateFocusTarget="True" PointerOverForeground="{ThemeResource GridViewItemForegroundPointerOver}" PressedBackground="{ThemeResource GridViewItemBackgroundPressed}" PlaceholderBackground="{ThemeResource GridViewItemPlaceholderBackground}" PointerOverBackground="{ThemeResource GridViewItemBackgroundPointerOver}" ReorderHintOffset="{ThemeResource GridViewItemReorderHintThemeOffset}" SelectedPressedBackground="{ThemeResource GridViewItemBackgroundSelectedPressed}" SelectionCheckMarkVisualEnabled="{ThemeResource GridViewItemSelectionCheckMarkVisualEnabled}" SelectedForeground="{ThemeResource GridViewItemForegroundSelected}" SelectedPointerOverBackground="{ThemeResource GridViewItemBackgroundSelectedPointerOver}" SelectedBackground="{ThemeResource GridViewItemBackgroundSelected}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>

    After that, I tried to deploy my app, this error appeared:

    Type 'TemplateBinding' used after '{' must be a Markup Extension. Error code 0x09c4. in ListViewItemPresenter section of XAML code.

    How can I fix this ?

    Thanks.


    Thursday, November 3, 2016 9:30 AM

Answers

  • Hello berkbaba,

    I tested with the case and I stopped at the following like you:

    So I checked the document about it and it seems it's device family is "Universal, introduced version 10.0.14393.0". Which is related to 14393 SDK. 

    So you may need to change the target like this:

    Best regards,

    Barry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by berkbaba Friday, November 4, 2016 2:10 PM
    Friday, November 4, 2016 3:19 AM
    Moderator