항목을 클릭하면 첫 번째 항목의 스토리 보드에서만 작동합니다.[UWP] DataTemplate에 포함 된 스토리 보드가 제대로 작동하지 않습니다.
아래 주소에서 소스를 다운로드 할 수 있습니다.
http://util.aquerytool.com/Download?fileName=ItemStoryboardApp.zip
는 답장을 보내 주셔서 감사합니다.<UserControl
x:Class="ItemStoryboardApp.View.ItemListMVVMLightView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:ItemStoryboardApp.View"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:core="using:Microsoft.Xaml.Interactions.Core"
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
xmlns:media="using:Microsoft.Xaml.Interactions.Media"
mc:Ignorable="d"
d:DesignHeight="300"
d:DesignWidth="400">
<Grid x:Name="PART_RootPanel">
<ItemsControl ItemsSource="{Binding ItemList}" Padding="0,0,0,0">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Button Foreground="White" Margin="0,0,5,0" Padding="0,0,0,0" Height="40" Command="{Binding DataContext.SelectedItemCommand, ElementName=PART_RootPanel}" CommandParameter="{Binding}" VerticalContentAlignment="Stretch" >
<Button.Content>
<Grid x:Name="PART_ContinuousDefectPanel" RenderTransformOrigin="0.5, 0.5">
<Grid.Resources>
<Storyboard x:Name="SB_ChangedCount">
<DoubleAnimation Storyboard.TargetName="PART_ContinuousDefectPanel" Duration="0:0:0.25" To="1.2" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleX)" AutoReverse="True" />
<DoubleAnimation Storyboard.TargetName="PART_ContinuousDefectPanel" Duration="0:0:0.25" To="1.2" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleY)" AutoReverse="True" />
</Storyboard>
</Grid.Resources>
<Grid.RenderTransform>
<ScaleTransform x:Name="ImageScale" ScaleX="1" ScaleY="1" />
</Grid.RenderTransform>
<interactivity:Interaction.Behaviors>
<core:DataTriggerBehavior Binding="{Binding IsSelected}" Value="True" ComparisonCondition="Equal">
<media:ControlStoryboardAction Storyboard="{StaticResource SB_ChangedCount}" />
</core:DataTriggerBehavior>
</interactivity:Interaction.Behaviors>
<Rectangle Fill="Orange" RadiusX="10" RadiusY="10"/>
<StackPanel Orientation="Horizontal" Margin="10,0,10,0" VerticalAlignment="Center">
<TextBlock Text="{Binding ItemName}" />
</StackPanel>
</Grid>
</Button.Content>
</Button>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
</UserControl>
public class ItemListMVVMLightViewModel : ViewModelBase
{
public ObservableCollection<ItemModel> ItemList
{
get { return _itemList; }
set { _itemList = value; RaisePropertyChanged("ItemList"); }
}
ObservableCollection<ItemModel> _itemList = new ObservableCollection<ItemModel>();
public ICommand SelectedItemCommand { get; private set; }
public ItemListMVVMLightViewModel()
{
InitData();
InitCommand();
}
void InitCommand()
{
SelectedItemCommand = new RelayCommand<object>((param) => OnSelectedItemCommand(param));
}
void InitData()
{
for (int i = 0; i < 10; i++)
{
ItemList.Add(new ItemModel() { ItemName = "Name" + i.ToString() });
}
}
void OnSelectedItemCommand(object param)
{
if (param == null || (param is ItemModel) == false)
{
return;
}
foreach (ItemModel i in ItemList)
{
i.IsSelected = false;
}
ItemModel item = param as ItemModel;
item.IsSelected = true;
}
}
여기에 관련 코드를 링크 된 우편 번호로 입력하십시오. –