-
-
Save magegu/0e0bd53fcef25ce6aa81 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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