The following forum(s) are migrating to a new home on Microsoft Q&A (Preview): Developing Universal Windows apps!

Ask new questions on Microsoft Q&A (Preview).
Interact with existing posts until December 13, 2019, after which content will be closed to all new and existing posts.

Learn More

 none
[UWP][Xaml]Custom ListViewItem RRS feed

  • Question

  • Hello guys

    I am trying to make my own custom ListViewItem.

    I did create a TemplatedControl

    Namespace UI.Controls
        Public NotInheritable Class ChatFriendsViewItem
            Inherits ListViewItem
    
            Public Sub New()
                Me.Avatar = Nothing
                Me.DisplayName = String.Empty
                Me.DisplayState = String.Empty
                Me.DefaultStyleKey = GetType(ChatFriendsViewItem)
            End Sub
    
            Public Shared ReadOnly AvatarProperty As DependencyProperty = DependencyProperty.Register("Avatar", GetType(BitmapImage), GetType(ViewModelItem), New PropertyMetadata(Nothing))
    
            Public Property Avatar() As BitmapImage
                Get
                    Return DirectCast(GetValue(AvatarProperty), BitmapImage)
                End Get
                Set(ByVal value As BitmapImage)
                    SetValue(AvatarProperty, value)
                End Set
            End Property
    
            Public Shared ReadOnly DisplayNameProperty As DependencyProperty = DependencyProperty.Register("DisplayName", GetType(String), GetType(ViewModelItem), New PropertyMetadata(Nothing))
    
            Public Property DisplayName() As String
                Get
                    Return DirectCast(GetValue(DisplayNameProperty), String)
                End Get
                Set(ByVal value As String)
                    SetValue(DisplayNameProperty, value)
                End Set
            End Property
    
            Public Shared ReadOnly DisplayStateProperty As DependencyProperty = DependencyProperty.Register("DisplayState", GetType(String), GetType(ViewModelItem), New PropertyMetadata(Nothing))
    
            Public Property DisplayState() As String
                Get
                    Return DirectCast(GetValue(DisplayStateProperty), String)
                End Get
                Set(ByVal value As String)
                    SetValue(DisplayStateProperty, value)
                End Set
            End Property
    
        End Class
    End Namespace


    and the style code is

        <Style TargetType="Controls:ChatFriendsViewItem">
            <Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}" />
            <Setter Property="FontSize" Value="{ThemeResource ControlContentThemeFontSize}" />
            <Setter Property="Background" Value="Transparent"/>
            <Setter Property="Foreground" Value="{ThemeResource SystemControlForegroundBaseHighBrush}" />
            <Setter Property="TabNavigation" Value="Local"/>
            <Setter Property="IsHoldingEnabled" Value="True"/>
            <Setter Property="Padding" Value="0"/>
            <Setter Property="HorizontalContentAlignment" Value="Left"/>
            <Setter Property="VerticalContentAlignment" Value="Center"/>
            <Setter Property="MinWidth" Value="{ThemeResource ListViewItemMinWidth}"/>
            <Setter Property="MinHeight" Value="{ThemeResource ListViewItemMinHeight}"/>
            <Setter Property="UseSystemFocusVisuals" Value="True" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Controls:ChatFriendsViewItem">
                        <Grid x:Name="ContentBorder"
                                  Background="{TemplateBinding Background}"
                                  BorderBrush="{TemplateBinding BorderBrush}"
                                  BorderThickness="{TemplateBinding BorderThickness}">
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="CommonStates">
                                    <VisualState x:Name="Normal">
                                        <Storyboard>
                                            <PointerUpThemeAnimation Storyboard.TargetName="ContentPresenter" />
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="PointerOver">
                                        <Storyboard>
                                            <DoubleAnimation Storyboard.TargetName="BorderBackground"
                                                                 Storyboard.TargetProperty="Opacity"
                                                                 Duration="0"
                                                                 To="1"/>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="BorderBackground" Storyboard.TargetProperty="Fill">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightListLowBrush}" />
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Foreground">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightAltBaseHighBrush}" />
                                            </ObjectAnimationUsingKeyFrames>
                                            <PointerUpThemeAnimation Storyboard.TargetName="ContentPresenter" />
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Pressed">
                                        <Storyboard>
                                            <DoubleAnimation Storyboard.TargetName="BorderBackground"
                                                                 Storyboard.TargetProperty="Opacity"
                                                                 Duration="0"
                                                                 To="1"/>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="BorderBackground" Storyboard.TargetProperty="Fill">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightListMediumBrush}" />
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Foreground">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightAltBaseHighBrush}" />
                                            </ObjectAnimationUsingKeyFrames>
                                            <PointerDownThemeAnimation TargetName="ContentPresenter" />
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Selected">
                                        <Storyboard>
                                            <DoubleAnimation Storyboard.TargetName="MultiSelectCheck"
                                                                 Storyboard.TargetProperty="Opacity"
                                                                 Duration="0:0:0"
                                                                 To="1"/>
                                            <DoubleAnimation Storyboard.TargetName="BorderBackground"
                                                                 Storyboard.TargetProperty="Opacity"
                                                                 Duration="0"
                                                                 To="1"/>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="BorderBackground" Storyboard.TargetProperty="Fill">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightListAccentLowBrush}" />
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Foreground">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightAltBaseHighBrush}" />
                                            </ObjectAnimationUsingKeyFrames>
                                            <PointerUpThemeAnimation Storyboard.TargetName="ContentPresenter" />
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="PointerOverSelected">
                                        <Storyboard>
                                            <DoubleAnimation Storyboard.TargetName="MultiSelectCheck"
                                                                 Storyboard.TargetProperty="Opacity"
                                                                 Duration="0:0:0"
                                                                 To="1"/>
                                            <DoubleAnimation Storyboard.TargetName="BorderBackground"
                                                                 Storyboard.TargetProperty="Opacity"
                                                                 Duration="0"
                                                                 To="1"/>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="BorderBackground" Storyboard.TargetProperty="Fill">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightListAccentMediumBrush}" />
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Foreground">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightAltBaseHighBrush}" />
                                            </ObjectAnimationUsingKeyFrames>
                                            <PointerUpThemeAnimation Storyboard.TargetName="ContentPresenter" />
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="PressedSelected">
                                        <Storyboard>
                                            <DoubleAnimation Storyboard.TargetName="MultiSelectCheck"
                                                                 Storyboard.TargetProperty="Opacity"
                                                                 Duration="0:0:0"
                                                                 To="1"/>
                                            <DoubleAnimation Storyboard.TargetName="BorderBackground"
                                                                 Storyboard.TargetProperty="Opacity"
                                                                 Duration="0"
                                                                 To="1"/>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="BorderBackground" Storyboard.TargetProperty="Fill">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightListAccentHighBrush}" />
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter" Storyboard.TargetProperty="Foreground">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightAltBaseHighBrush}" />
                                            </ObjectAnimationUsingKeyFrames>
                                            <PointerDownThemeAnimation TargetName="ContentPresenter" />
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="DisabledStates">
                                    <VisualState x:Name="Enabled"/>
                                    <VisualState x:Name="Disabled">
                                        <Storyboard>
                                            <DoubleAnimation Storyboard.TargetName="ContentBorder"
                                                                 Storyboard.TargetProperty="Opacity"
                                                                 Duration="0"
                                                                 To="{ThemeResource ListViewItemDisabledThemeOpacity}"/>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="MultiSelectStates">
                                    <VisualState x:Name="MultiSelectDisabled">
                                        <Storyboard>
                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="MultiSelectCheckBoxTransform" Storyboard.TargetProperty="X">
                                                <EasingDoubleKeyFrame KeyTime="0:0:0" Value="0"/>
                                                <SplineDoubleKeyFrame KeyTime="0:0:0.333" Value="-32" KeySpline="0.1,0.9,0.2,1"/>
                                            </DoubleAnimationUsingKeyFrames>
                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="MultiSelectClipTransform" Storyboard.TargetProperty="X">
                                                <EasingDoubleKeyFrame KeyTime="0:0:0" Value="0"/>
                                                <SplineDoubleKeyFrame KeyTime="0:0:0.333" Value="32" KeySpline="0.1,0.9,0.2,1"/>
                                            </DoubleAnimationUsingKeyFrames>
                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenterTranslateTransform" Storyboard.TargetProperty="X">
                                                <EasingDoubleKeyFrame KeyTime="0:0:0" Value="32"/>
                                                <SplineDoubleKeyFrame KeyTime="0:0:0.333" Value="0" KeySpline="0.1,0.9,0.2,1"/>
                                            </DoubleAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="MultiSelectSquare" Storyboard.TargetProperty="Visibility">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="Visible" />
                                                <DiscreteObjectKeyFrame KeyTime="0:0:0.333" Value="Collapsed" />
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="MultiSelectEnabled">
                                        <Storyboard>
                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="MultiSelectCheckBoxTransform" Storyboard.TargetProperty="X">
                                                <EasingDoubleKeyFrame KeyTime="0:0:0" Value="-32"/>
                                                <SplineDoubleKeyFrame KeyTime="0:0:0.333" Value="0" KeySpline="0.1,0.9,0.2,1"/>
                                            </DoubleAnimationUsingKeyFrames>
                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="MultiSelectClipTransform" Storyboard.TargetProperty="X">
                                                <EasingDoubleKeyFrame KeyTime="0:0:0" Value="32"/>
                                                <SplineDoubleKeyFrame KeyTime="0:0:0.333" Value="0" KeySpline="0.1,0.9,0.2,1"/>
                                            </DoubleAnimationUsingKeyFrames>
                                            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenterTranslateTransform" Storyboard.TargetProperty="X">
                                                <EasingDoubleKeyFrame KeyTime="0:0:0" Value="-32"/>
                                                <SplineDoubleKeyFrame KeyTime="0:0:0.333" Value="0" KeySpline="0.1,0.9,0.2,1"/>
                                            </DoubleAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="MultiSelectSquare" Storyboard.TargetProperty="Visibility">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="Visible" />
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="MultiSelectCheck" Storyboard.TargetProperty="Visibility">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="Visible" />
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenterGrid" Storyboard.TargetProperty="Margin">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="32,0,0,0" />
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="DataVirtualizationStates">
                                    <VisualState x:Name="DataAvailable"/>
                                    <VisualState x:Name="DataPlaceholder">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PlaceholderTextBlock" Storyboard.TargetProperty="Visibility">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="Visible" />
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PlaceholderRect" Storyboard.TargetProperty="Visibility">
                                                <DiscreteObjectKeyFrame KeyTime="0" Value="Visible" />
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="ReorderHintStates">
                                    <VisualState x:Name="NoReorderHint"/>
                                    <VisualState x:Name="BottomReorderHint">
                                        <Storyboard>
                                            <DragOverThemeAnimation TargetName="ContentBorder" ToOffset="{ThemeResource ListViewItemReorderHintThemeOffset}" Direction="Bottom" />
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="TopReorderHint">
                                        <Storyboard>
                                            <DragOverThemeAnimation TargetName="ContentBorder" ToOffset="{ThemeResource ListViewItemReorderHintThemeOffset}" Direction="Top" />
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="RightReorderHint">
                                        <Storyboard>
                                            <DragOverThemeAnimation TargetName="ContentBorder" ToOffset="{ThemeResource ListViewItemReorderHintThemeOffset}" Direction="Right" />
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="LeftReorderHint">
                                        <Storyboard>
                                            <DragOverThemeAnimation TargetName="ContentBorder" ToOffset="{ThemeResource ListViewItemReorderHintThemeOffset}" Direction="Left" />
                                        </Storyboard>
                                    </VisualState>
                                    <VisualStateGroup.Transitions>
                                        <VisualTransition To="NoReorderHint" GeneratedDuration="0:0:0.2"/>
                                    </VisualStateGroup.Transitions>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="DragStates">
                                    <VisualState x:Name="NotDragging" />
                                    <VisualState x:Name="Dragging">
                                        <Storyboard>
                                            <DoubleAnimation Storyboard.TargetName="ContentBorder"
                                                                 Storyboard.TargetProperty="Opacity"
                                                                 Duration="0"
                                                                 To="{ThemeResource ListViewItemDragThemeOpacity}" />
                                            <DragItemThemeAnimation TargetName="ContentBorder" />
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="DraggingTarget">
                                        <Storyboard>
                                            <DropTargetItemThemeAnimation TargetName="ContentBorder" />
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="MultipleDraggingPrimary">
                                        <Storyboard>
                                            <!-- These two Opacity animations are required - the FadeInThemeAnimations
                                             on the same elements animate an internal Opacity. -->
                                            <DoubleAnimation Storyboard.TargetName="MultiArrangeOverlayBackground"
                                                                 Storyboard.TargetProperty="Opacity"
                                                                 Duration="0"
                                                                 To="1" />
                                            <DoubleAnimation Storyboard.TargetName="MultiArrangeOverlayText"
                                                                 Storyboard.TargetProperty="Opacity"
                                                                 Duration="0"
                                                                 To="1" />
                                            <DoubleAnimation Storyboard.TargetName="ContentBorder"
                                                                 Storyboard.TargetProperty="Opacity"
                                                                 Duration="0"
                                                                 To="{ThemeResource ListViewItemDragThemeOpacity}" />
                                            <FadeInThemeAnimation TargetName="MultiArrangeOverlayBackground" />
                                            <FadeInThemeAnimation TargetName="MultiArrangeOverlayText" />
                                            <DragItemThemeAnimation TargetName="ContentBorder" />
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="MultipleDraggingSecondary">
                                        <Storyboard>
                                            <FadeOutThemeAnimation TargetName="ContentBorder" />
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="DraggedPlaceholder">
                                        <Storyboard>
                                            <FadeOutThemeAnimation TargetName="ContentBorder" />
                                        </Storyboard>
                                    </VisualState>
                                    <VisualStateGroup.Transitions>
                                        <VisualTransition To="NotDragging" GeneratedDuration="0:0:0.2"/>
                                    </VisualStateGroup.Transitions>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="VisualModeStates">
    
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                            <Rectangle x:Name="BorderBackground"
                                           IsHitTestVisible="False"
                                           Fill="{ThemeResource SystemControlHighlightListAccentLowBrush}"
                                           Opacity="0"
                                           Control.IsTemplateFocusTarget="True"/>
                            <!-- Contents are here. -->
                            <Grid x:Name="ContentPresenterGrid"
                                      Width="380"
                                      Background="Transparent"
                                      HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                      VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                      Margin="{TemplateBinding Padding}">
                                <Grid.RenderTransform>
                                    <TranslateTransform x:Name="ContentPresenterTranslateTransform"/>
                                </Grid.RenderTransform>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="Auto"/>
                                </Grid.ColumnDefinitions>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="*"/>
                                    <RowDefinition Height="Auto"/>
                                </Grid.RowDefinitions>
                                <Ellipse x:Name="AvatarImage" Grid.Column="0" Grid.Row="0" Margin="10" Width="50" Height="50">
                                    <Ellipse.Fill>
                                        <ImageBrush/>
                                    </Ellipse.Fill>
                                </Ellipse>
                                <Grid Grid.Column="1" Grid.Row="0" Margin="14">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="*"/>
                                        <ColumnDefinition Width="Auto"/>
                                    </Grid.ColumnDefinitions>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="Auto"/>
                                    </Grid.RowDefinitions>
                                    <TextBlock Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2" VerticalAlignment="Bottom" FontSize="18" Text="{TemplateBinding DisplayName}"/>
                                    <TextBlock Grid.Column="0" Grid.Row="1" Grid.RowSpan="2" VerticalAlignment="Stretch" FontSize="24" Text="{TemplateBinding DisplayState}"/>
                                    <TextBlock Grid.Column="1" Grid.Row="1" Grid.ColumnSpan="2" Margin="8,0,0,0" FontSize="12" Text="Online for 3 hours"/>
                                    <TextBlock Grid.Column="1" Grid.Row="2" Grid.ColumnSpan="2" Margin="8,0,0,0" FontSize="14" Text="Path of Exile"/>
                                    <Button Grid.Column="2" Padding="2" Style="{StaticResource StyleButtonGlyph}" Content="I"/>
                                </Grid>
                                <Grid Grid.Column="3" Grid.Row="0" Margin="0" VerticalAlignment="Top">
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="Auto"/>
                                        <ColumnDefinition Width="Auto"/>
                                    </Grid.ColumnDefinitions>
                                    <Button Grid.Column="0" Margin="6" Padding="6,3,6,7" Style="{StaticResource StyleButtonGlyph}" Content="&#xE717;"/>
                                </Grid>
                            </Grid>
                            <!-- The 'Xg' text simulates the amount of space one line of text will occupy.
                              In the DataPlaceholder state, the Content is not loaded yet so we
                              approximate the size of the item using placeholder text. -->
                            <TextBlock x:Name="PlaceholderTextBlock"
                                           Opacity="0"
                                           Text="Xg"
                                           Foreground="{x:Null}"
                                           Margin="{TemplateBinding Padding}"
                                           IsHitTestVisible="False"
                                           AutomationProperties.AccessibilityView="Raw"/>
                            <Rectangle x:Name="PlaceholderRect"
                                           Visibility="Collapsed"
                                           Fill="{ThemeResource ListViewItemPlaceholderBackgroundThemeBrush}"/>
                            <Rectangle x:Name="MultiArrangeOverlayBackground"
                                           IsHitTestVisible="False"
                                           Opacity="0"
                                           Fill="{ThemeResource ListViewItemDragBackgroundThemeBrush}"
                                           Grid.ColumnSpan="2"/>
                            <Border x:Name="MultiSelectSquare"
                                        BorderBrush="{ThemeResource SystemControlForegroundBaseMediumHighBrush}"
                                        BorderThickness="2"
                                        Width="20"
                                        Height="20"
                                        Margin="12,0,0,0"
                                        VerticalAlignment="Center"
                                        HorizontalAlignment="Left"
                                        Visibility="Collapsed">
                                <Border.Clip>
                                    <RectangleGeometry Rect="0,0,20,20">
                                        <RectangleGeometry.Transform>
                                            <TranslateTransform x:Name="MultiSelectClipTransform"/>
                                        </RectangleGeometry.Transform>
                                    </RectangleGeometry>
                                </Border.Clip>
                                <Border.RenderTransform>
                                    <TranslateTransform x:Name="MultiSelectCheckBoxTransform"/>
                                </Border.RenderTransform>
                                <FontIcon x:Name="MultiSelectCheck"
                                              FontFamily="{ThemeResource SymbolThemeFontFamily}"
                                              Glyph="&#xE73E;"
                                              FontSize="16"
                                              Foreground="{ThemeResource SystemControlForegroundBaseMediumHighBrush}"
                                              Visibility="Collapsed"
                                              Opacity="0"/>
                            </Border>
                            <TextBlock x:Name="MultiArrangeOverlayText"
                                           Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TemplateSettings.DragItemsCount}"
                                           Foreground="{ThemeResource ListViewItemDragForegroundThemeBrush}"
                                           FontFamily="{ThemeResource ContentControlThemeFontFamily}"
                                           FontSize="26.667"
                                           IsHitTestVisible="False"
                                           Opacity="0"
                                           TextWrapping="Wrap"
                                           TextTrimming="WordEllipsis"
                                           Margin="18,9,0,0"
                                           AutomationProperties.AccessibilityView="Raw"
                                           Grid.ColumnSpan="2"/>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

    and the ListView that present the elements

    <ListView Name="ListView_FriendsList" Visibility="Visible" IsItemClickEnabled="True" SelectionMode="Single" SelectionChanged="ListView_FriendsList_SelectionChanged">
                <ListView.ItemTemplate>
                    <DataTemplate x:DataType="ChatFriendsModel:ChatFriendData">
                        <local:ChatFriendsViewItem DisplayName="{x:Bind DisplayName, Mode=OneWay}"/>
                    </DataTemplate>
                </ListView.ItemTemplate>
                <ListView.ItemContainerStyle>
                    <Style TargetType="ListViewItem">
                        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
                        <Setter Property="Padding" Value="0"/>
                        <Setter Property="Margin" Value="0"/>
                    </Style>
                </ListView.ItemContainerStyle>
    </ListView>

    but when the app tries to load the elements i get this error

    The property 'DisplayName' was not found in type '***.UI.Controls.ChatFriendsViewItem'. [Line: 316 Position: 134]


    Saturday, July 14, 2018 2:06 AM

Answers

  • Hi,

    I did do as you said, and i got a new error, but it says that the attached debugger cannot debug this unhanded exception, and it asks me to change the debugger.

    Edit 1:I also tried to change the type of ChatFriendsViewItem from Usercontrol to TemplatedControl, but the same thing happens.

    Edit 2:I also tried to add FriendsItems directly to the list not using ItemsSource, The same error, now i am sure that the problem is with the ChatFriendsViewItem Style, but i don't know what is it exactly, i created the style by taking the default listviewitem style, replace ContentPresenter with a grid that contains the content, and finally i edited the storyboards

    Edit 3:I checked the style again, i found out that the problem is inside the storyboards of the common states, there are some ObjectAnimationUsingKeyFrames that attempt to change the foreground of the ContentPresenter which i removed, so i commented them out and it worked.

    Thanks in advance






    • Edited by Lersubem Saturday, July 21, 2018 9:47 AM
    • Marked as answer by Lersubem Sunday, July 22, 2018 10:49 PM
    Saturday, July 21, 2018 9:08 AM

All replies

  • Hi,

    From the error message, it said the property is not found. I checked the code in your custom class, you are registering your property to a ViewModelItem instead of the ChatFriendsViewItem class. What is that class? Have you tried to change it to ChatFriendsViewItem class and  try it again?

    Bet regards,

    Roy


    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.

    Monday, July 16, 2018 4:15 AM
    Moderator
  • Hi,

    I did do as you said, and i got a new error, but it says that the attached debugger cannot debug this unhanded exception, and it asks me to change the debugger.

    Edit 1:I also tried to change the type of ChatFriendsViewItem from Usercontrol to TemplatedControl, but the same thing happens.

    Edit 2:I also tried to add FriendsItems directly to the list not using ItemsSource, The same error, now i am sure that the problem is with the ChatFriendsViewItem Style, but i don't know what is it exactly, i created the style by taking the default listviewitem style, replace ContentPresenter with a grid that contains the content, and finally i edited the storyboards

    Edit 3:I checked the style again, i found out that the problem is inside the storyboards of the common states, there are some ObjectAnimationUsingKeyFrames that attempt to change the foreground of the ContentPresenter which i removed, so i commented them out and it worked.

    Thanks in advance






    • Edited by Lersubem Saturday, July 21, 2018 9:47 AM
    • Marked as answer by Lersubem Sunday, July 22, 2018 10:49 PM
    Saturday, July 21, 2018 9:08 AM