public partial class FullscreenPage : PhoneApplicationPage | |
{ | |
Item item; | |
public FullscreenPage() | |
{ | |
InitializeComponent(); | |
} | |
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) | |
{ | |
base.OnNavigatedTo(e); | |
string objectId; | |
NavigationContext.QueryString.TryGetValue("ObjectId", out objectId); | |
var itemsDB = new ItemsContext(ItemsContext.DBConnectionString); | |
item = (from r in itemsDB.artifacts where r.Id.Equals(objectId) select r).First(); | |
} | |
} |
<ContentControl ContentTemplate="{Binding}"> | |
<testapp:FullscreenTypeSelector> | |
<testapp:FullscreenTypeSelector.ImageTemplate> | |
<ControlTemplate> | |
<StackPanel> | |
<Image Name="Image" Source="{Binding PayloadUri}"/> | |
</StackPanel> | |
</ControlTemplate> | |
</testapp:FullscreenTypeSelector.ImageTemplate> | |
<testapp:FullscreenTypeSelector.TextTemplate> | |
<ControlTemplate> | |
<StackPanel> | |
<TextBlock Name="MimeText" Text="{Binding Mime}"/> | |
</StackPanel> | |
</ControlTemplate> | |
</testapp:FullscreenTypeSelector.ImageTemplate> | |
</testapp:FullscreenTypeSelector> | |
</ContentControl> |
public class FullscreenTypeSelector : ContentControl | |
{ | |
public ControlTemplate ImageTemplate | |
{ | |
get; | |
set; | |
} | |
public ControlTemplate TextTemplate | |
{ | |
get; | |
set; | |
} | |
//Use ContentControl as a container and bind ContentTemplate property to your DataTemplateSelector. | |
ControlTemplate SelectTemplate(object item, DependencyObject container) | |
{ | |
Item foodItem = item as Item; | |
if (foodItem != null) | |
{ | |
if (foodItem.Mime == "note") | |
{ | |
return TextTemplate; | |
} | |
else | |
{ | |
return ImageTemplate; | |
} | |
} | |
return null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment