@EboLiK

Как получить элемент ListView при наведении на него курсора используя mvvm?

Суть в том, что при наведении на элемент у меня должен border стать видимым, а textblock внутри должен иметь такой же текст, как у textblock который биндиться от "Name", который находиться внутри ListView.

Вот код xaml:
<ListView BorderThickness="0"
                                  ItemsSource="{Binding Mods}"
                                  Background="Transparent"
                                  ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                                  SelectedItem="{Binding SelectedItem}">
                            <ListView.ItemContainerStyle>

                                <Style TargetType="ListViewItem">
                                    <Setter Property="HorizontalAlignment" Value="Stretch"/>
                                    <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
                                    <Setter Property="Padding" Value="0"/>
                                    <Setter Property="BorderThickness" Value="0"/>
                                </Style>

                            </ListView.ItemContainerStyle>
                            <ListView.ItemTemplate>
                                <DataTemplate>
                                    <Border Height="110"
                                            Background="#222E1F"
                                            Margin="20, 20, 20, 10"
                                            CornerRadius="3">

                                        <Border.Effect>
                                            <DropShadowEffect Opacity="0.25"/>
                                        </Border.Effect>

                                        <Grid>
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="230"/>
                                                <ColumnDefinition Width="220*"/>
                                            </Grid.ColumnDefinitions>

                                            <Border CornerRadius="3">

                                                <Border.Effect>
                                                    <DropShadowEffect BlurRadius="4"
                                                                      Opacity="0.25"
                                                                      Direction="360"
                                                                      ShadowDepth="4"/>
                                                </Border.Effect>

                                                <Border.Background>
                                                    <ImageBrush Stretch="UniformToFill"/>
                                                </Border.Background>
                                            </Border>

                                            <StackPanel Grid.Column="1"
                                                        Orientation="Vertical"
                                                        VerticalAlignment="Center"
                                                        Margin="15,0,0,0">

                                                <TextBlock Text="{Binding Name}"
                                                           FontSize="24"/>

                                                <TextBlock Margin="0,10,0,10">
                                                    <Run Text="Текущая версия мода: "
                                                         FontSize="15"/>
                                                    <Run Text="{Binding Name}"
                                                         FontSize="15"
                                                         FontWeight="Bold"/>
                                                    <Run Text="{Binding Version}"
                                                         FontSize="15"/>
                                                </TextBlock>

                                                <TextBlock Text="{Binding Theme}"
                                                           FontSize="15"/>
                                            </StackPanel>
                                            
                                        </Grid>
                                    </Border>
                                </DataTemplate>
                            </ListView.ItemTemplate>

                        </ListView>
                        <Border Grid.Column="1"
                                Margin="20"
                                Background="#30402C"
                                Visibility="Hidden">

                            <TextBlock Text="Текст мажок экспериментал"
                                       FontSize="24" 
                                       TextAlignment="Center"
                                       HorizontalAlignment="Center" 
                                       VerticalAlignment="Top"
                                       TextWrapping="Wrap"/>

                        </Border>


Тут в конце есть border который как раз и нужно сделать видимым и внутри изменить текст.

Класс C#:
using Rusted_Warfare_Hub.Model;
using Rusted_Warfare_Hub.Model.Repositories;
using System.Collections.Generic;
using System.Threading;

namespace Rusted_Warfare_Hub.ViewModels
{
    public class ModsVM : VMBase
    {
        private List<Mod> _mods { get; set; }
        private ModRepository _modRepository { get; set; }

        public List<Mod> Mods
        {
            get => _mods;
            set
            {
                _mods = value;
                OnPropertyChanged(nameof(Mods));
            }
        }

        public ModsVM() 
        {
            _modRepository = new ModRepository();
            Mods = _modRepository.GetMods();
        }
    }
}
  • Вопрос задан
  • 59 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы