It really depends on your model: Do you use data binding? The easiest way might be to bind to the SelectedItem property of your playlist and use a Converter:
<AppBarButton Label="Fullscreen" IsEnabled="{Binding ElementName=playlistListBox, Path=SelectedItem.Type, Converter="{StaticResource ContextualConverter}, ConverterParameter=fullscreenIsEnabled}" />
And the Converter:
using System;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Data;
...
public class SampleConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string culture)
{
switch (parameter as string)
{
case "fullscreenIsEnabled": return ((value as MediaType) == MediaType.Video);//return true for video files
}
return null;
}
public object ConvertBack(object value, Type targetType, object parameter, string culture)
{
throw new NotImplementedException();
}
}
happy new year!
Life is unsure - always eat the dessert first!
No comments:
Post a Comment