secret
Last active

  • Download Gist
page.cs
C#
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
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();
 
}
}
page.xaml
XML
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
<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>
selector.cs
C#
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
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;
}
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.