Created
October 12, 2017 16:05
-
-
Save terriblememory/78f1faca77941c43c4a887025e370ee5 to your computer and use it in GitHub Desktop.
XamlCompositionBrushBase example
This file contains hidden or 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 ExampleBrush : XamlCompositionBrushBase | |
{ | |
protected override void OnConnected() | |
{ | |
if (CompositionBrush == null) | |
{ | |
var compositor = Window.Current.Compositor; | |
var bitmapUri = new System.Uri("ms-appx:///Assets/StoreLogo.png"); | |
var bitmapSurface = LoadedImageSurface.StartLoadFromUri(bitmapUri); | |
var bitmapBrush = compositor.CreateSurfaceBrush(bitmapSurface); | |
bitmapBrush.Stretch = CompositionStretch.None; | |
CompositionBrush = bitmapBrush; | |
} | |
} | |
protected override void OnDisconnected() | |
{ | |
if (CompositionBrush != null) | |
{ | |
CompositionBrush.Dispose(); | |
CompositionBrush = null; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment