Video fills Online
This sample demonstrates the ability to create a SimpleFillSymbol that contains a VideoBrush. One state, California, is loaded as a FeatureLayer and has its video fill applied in XAML via the FeatureSymbol property. A GraphicsLayer is initialized in the code-behind with Graphics for a number of other western states. For these graphics, a MouseEnter handler demonstrates applying a video fill dynamically in code.
Download Sample Application<UserControl x:Class="ArcGISWPFSDK.VideoFills" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:esri="http://schemas.esri.com/arcgis/client/2009"> <Grid x:Name="LayoutRoot" Background="White"> <Grid.Resources> <!--<esri:DictionaryConverter x:Key="MyDictionaryConverter" />--> <esri:FillSymbol x:Key="videoFill"> <esri:FillSymbol.ControlTemplate> <ControlTemplate> <Path x:Name="Element" Stroke="Gray" StrokeThickness="2" MouseLeave="Element_MouseLeave" MouseEnter="Element_MouseEnter" > <Path.Fill> <VisualBrush Stretch="UniformToFill"> <VisualBrush.Visual> <MediaElement x:Name="stateVideo" LoadedBehavior="Manual" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" Source="{Binding Attributes[Attributes]}" IsMuted="True" MediaEnded="State_Media_MediaEnded" /> </VisualBrush.Visual> </VisualBrush> </Path.Fill> <VisualStateManager.VisualStateGroups> <VisualStateGroup x:Name="CommonStates"> <VisualState x:Name="Normal"> <Storyboard> <DoubleAnimation To="0" Storyboard.TargetName="stateVideo" Storyboard.TargetProperty="Opacity" Duration="0" /> </Storyboard> </VisualState> <VisualState x:Name="MouseOver"> <Storyboard> <DoubleAnimation To=".75" Storyboard.TargetName="stateVideo" Storyboard.TargetProperty="Opacity" Duration="0" /> </Storyboard> </VisualState> </VisualStateGroup> </VisualStateManager.VisualStateGroups> </Path> </ControlTemplate> </esri:FillSymbol.ControlTemplate> </esri:FillSymbol> <VisualBrush Opacity="0.5" Stretch="UniformToFill" x:Key="BearVideoBrush"> <VisualBrush.Visual> <MediaElement x:Name="BearVideo" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" Source="http://serverapps.esri.com/media/bear.wmv" IsMuted="True" MediaEnded="State_Media_MediaEnded" /> </VisualBrush.Visual> </VisualBrush> <esri:SimpleRenderer x:Key="BearVideoFillRenderer"> <esri:SimpleRenderer.Symbol> <esri:SimpleFillSymbol Fill="{StaticResource BearVideoBrush}" BorderBrush="Green" BorderThickness="1"/> </esri:SimpleRenderer.Symbol> </esri:SimpleRenderer> <esri:SimpleFillSymbol x:Name="StateVideoFillSymbol" x:Key="StateVideoFillSymbol" BorderBrush="Transparent" BorderThickness="0" > </esri:SimpleFillSymbol> <esri:SimpleFillSymbol x:Name="TransparentFillSymbol" x:Key="TransparentFillSymbol" BorderBrush="#22000000" BorderThickness="1" Fill="#01000000" /> </Grid.Resources> <Grid x:Name="MediaGrid" Visibility="Hidden" /> <esri:Map x:Name="MyMap" Extent="-15000000,2000000,-7000000,8000000" WrapAround="True"> <esri:Map.Layers> <esri:ArcGISTiledMapServiceLayer ID="TopoLayer" Url="http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer"/> <esri:GraphicsLayer ID="MyGraphicsLayer" IsHitTestVisible="True" /> <esri:FeatureLayer ID="MyFeatureLayer" Url="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/2" Where="STATE_NAME = 'California'" Renderer="{StaticResource BearVideoFillRenderer}" > </esri:FeatureLayer> </esri:Map.Layers> </esri:Map> <TextBlock x:Name="lblError" Text="" Foreground="Red" Height="12"/> </Grid> </UserControl>
5/16/2014