too many to add
This commit is contained in:
@@ -12,4 +12,4 @@ public class DataTemplateConverter :
|
||||
{
|
||||
return new TemplateGenerator();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using Microsoft.UI.Xaml.Media;
|
||||
using Microsoft.UI.Xaml.Media.Imaging;
|
||||
using Windows.Storage.Streams;
|
||||
|
||||
namespace Hyperbar.UI.Windows;
|
||||
|
||||
public class StreamToImageSourceConverter :
|
||||
ValueConverter<Stream, ImageSource>
|
||||
{
|
||||
protected override ImageSource? ConvertTo(Stream value,
|
||||
Type? targetType,
|
||||
object? parameter,
|
||||
string? language)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
return default;
|
||||
}
|
||||
|
||||
IRandomAccessStream randomAccessStream =
|
||||
WindowsRuntimeStreamExtensions.AsRandomAccessStream(value);
|
||||
|
||||
BitmapImage bitmapImage = new();
|
||||
bitmapImage.SetSource(randomAccessStream);
|
||||
return bitmapImage;
|
||||
}
|
||||
}
|
||||
@@ -9,9 +9,14 @@ public class TemplateGenerator : DataTemplateSelector
|
||||
protected override DataTemplate SelectTemplateCore(object item)
|
||||
{
|
||||
string xamlString = @"
|
||||
<DataTemplate xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'
|
||||
xmlns:ui='using:Hyperbar.UI.Windows'>
|
||||
<ui:TemplateGeneratorControl />
|
||||
<DataTemplate xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
|
||||
xmlns:ui=""using:Hyperbar.UI.Windows"">
|
||||
<Grid>
|
||||
<ui:TemplateGeneratorControl VerticalContentAlignment=""Stretch""
|
||||
HorizontalContentAlignment=""Stretch""
|
||||
HorizontalAlignment=""Stretch""
|
||||
VerticalAlignment=""Stretch""/>
|
||||
</Grid>
|
||||
</DataTemplate>";
|
||||
|
||||
return (DataTemplate)XamlReader.Load(xamlString);
|
||||
@@ -20,9 +25,14 @@ public class TemplateGenerator : DataTemplateSelector
|
||||
protected override DataTemplate SelectTemplateCore(object item, DependencyObject container)
|
||||
{
|
||||
string xamlString = @"
|
||||
<DataTemplate xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'
|
||||
xmlns:ui='using:Hyperbar.UI.Windows'>
|
||||
<ui:TemplateGeneratorControl />
|
||||
<DataTemplate xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
|
||||
xmlns:ui=""using:Hyperbar.UI.Windows"">
|
||||
<Grid>
|
||||
<ui:TemplateGeneratorControl VerticalContentAlignment=""Stretch""
|
||||
HorizontalContentAlignment=""Stretch""
|
||||
HorizontalAlignment=""Stretch""
|
||||
VerticalAlignment=""Stretch""/>
|
||||
</Grid>
|
||||
</DataTemplate>";
|
||||
|
||||
return (DataTemplate)XamlReader.Load(xamlString);
|
||||
|
||||
@@ -17,9 +17,5 @@ public class TemplateGeneratorControl :
|
||||
{
|
||||
Content = templatedViewModel.TemplateFactory.Create(DataContext.GetType().Name);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user