Click here to Skip to main content
15,886,137 members
Articles / Web Development / HTML

WPF x FileExplorer x MVVM

Rate me:
Please Sign up or sign in to vote.
4.99/5 (52 votes)
24 Nov 2012LGPL323 min read 289.1K   9.4K   228  
This article describe how to construct FileExplorer controls included DirectoryTree and FileList, using Model-View-ViewModel (MVVM) pattern.
<ResourceDictionary
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:ProgressBarTest="clr-namespace:ProgressBarTest">
	<!-- Resource dictionary entries should be defined here. -->
	<!-- Resource dictionary entries should be defined here. -->
	<Style x:Key="BarbedWireProgressBarStyle"
		TargetType="{x:Type ProgressBarTest:CircularProgressBar}">
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type ProgressBarTest:CircularProgressBar}">
					<Grid SnapsToDevicePixels="true"
						DataContext="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ProgressBarTest:CircularProgressBar}}}">
						<Path>
							<Path.Fill>
								<RadialGradientBrush>
									<GradientStop Color="#FFBABABA" Offset=".87"/>
									<GradientStop Color="#FFC7C7C7" Offset="0.94"/>
									<GradientStop Color="#FFBABABA" Offset="1"/>
								</RadialGradientBrush>
							</Path.Fill>
							<Path.Data>
								<CombinedGeometry GeometryCombineMode="Union">
									<CombinedGeometry.Geometry1>
										<PathGeometry>
											<PathFigure StartPoint="75,0">
												<LineSegment Point="146.3,51.8" />
												<LineSegment Point="119.1,135.7" />
												<LineSegment Point="30.9,135.7" />
												<LineSegment Point="3.7, 51.8" />
											</PathFigure>
										</PathGeometry>
									</CombinedGeometry.Geometry1>
									<CombinedGeometry.Geometry2>
										<CombinedGeometry GeometryCombineMode="Exclude">
											<CombinedGeometry.Geometry1>
												<EllipseGeometry Center="75,75" RadiusX="75" RadiusY="75" />
											</CombinedGeometry.Geometry1>
											<CombinedGeometry.Geometry2>
												<EllipseGeometry Center="75,75" RadiusX="70" RadiusY="70" />
											</CombinedGeometry.Geometry2>
										</CombinedGeometry>
									</CombinedGeometry.Geometry2>
								</CombinedGeometry>
							</Path.Data>
							<Path.Clip>
								<CombinedGeometry GeometryCombineMode="Exclude">
									<CombinedGeometry.Geometry1>
										<EllipseGeometry Center="75,75" RadiusX="74" RadiusY="74" />
									</CombinedGeometry.Geometry1>
									<CombinedGeometry.Geometry2>
										<EllipseGeometry Center="75,75" RadiusX="66" RadiusY="66" />
									</CombinedGeometry.Geometry2>
								</CombinedGeometry>
							</Path.Clip>
						</Path>
						<Path Fill="#FF01D328">
							<Path.Data>
								<CombinedGeometry GeometryCombineMode="Intersect">
									<CombinedGeometry.Geometry1>
										<PathGeometry>
											<PathFigure StartPoint="0,0">
												<LineSegment Point="0,75" />
												<LineSegment Point="75,75" />
												<LineSegment Point="{Binding ProgressPoint}" />
												<LineSegment Point="{Binding ThirdBoundingPoint}" />
												<LineSegment Point="{Binding SecondBoundingPoint}" />
												<LineSegment Point="{Binding FirstBoundingPoint}" />
											</PathFigure>
										</PathGeometry>
									</CombinedGeometry.Geometry1>
									<CombinedGeometry.Geometry2>
										<CombinedGeometry GeometryCombineMode="Union">
											<CombinedGeometry.Geometry1>
												<PathGeometry>
													<PathFigure StartPoint="75,0">
														<LineSegment Point="146.3,51.8" />
														<LineSegment Point="119.1,135.7" />
														<LineSegment Point="30.9,135.7" />
														<LineSegment Point="3.7, 51.8" />
													</PathFigure>
												</PathGeometry>
											</CombinedGeometry.Geometry1>
											<CombinedGeometry.Geometry2>
												<CombinedGeometry GeometryCombineMode="Exclude">
													<CombinedGeometry.Geometry1>
														<EllipseGeometry Center="75,75" RadiusX="75" RadiusY="75" />
													</CombinedGeometry.Geometry1>
													<CombinedGeometry.Geometry2>
														<EllipseGeometry Center="75,75" RadiusX="70" RadiusY="70" />
													</CombinedGeometry.Geometry2>
												</CombinedGeometry>
											</CombinedGeometry.Geometry2>
										</CombinedGeometry>
									</CombinedGeometry.Geometry2>
								</CombinedGeometry>
							</Path.Data>
							<Path.Clip>
								<CombinedGeometry GeometryCombineMode="Exclude">
									<CombinedGeometry.Geometry1>
										<EllipseGeometry Center="75,75" RadiusX="74" RadiusY="74" />
									</CombinedGeometry.Geometry1>
									<CombinedGeometry.Geometry2>
										<EllipseGeometry Center="75,75" RadiusX="66" RadiusY="66" />
									</CombinedGeometry.Geometry2>
								</CombinedGeometry>
							</Path.Clip>
						</Path>
						<Ellipse>
							<Ellipse.Fill>
								<RadialGradientBrush>
									<GradientStop Color="#00FFFFFF" Offset="0.949"/>
									<GradientStop Color="#66FFFFFF" Offset="0.95"/>
									<!--
                        			<GradientStop Color="#FF202020" Offset=".87"/>
                        			<GradientStop Color="#FF747474" Offset=".9"/>
									<GradientStop Color="#FF747474" Offset=".97"/>
									<GradientStop Color="#FF202020" Offset="1"/>
									-->
								</RadialGradientBrush>
							</Ellipse.Fill>
							<Ellipse.Clip>
								<CombinedGeometry GeometryCombineMode="Exclude">
									<CombinedGeometry.Geometry1>
										<EllipseGeometry Center="75,75" RadiusX="75" RadiusY="75" />
									</CombinedGeometry.Geometry1>
									<CombinedGeometry.Geometry2>
										<EllipseGeometry Center="75,75" RadiusX="65" RadiusY="65" />
									</CombinedGeometry.Geometry2>
								</CombinedGeometry>
							</Ellipse.Clip>
						</Ellipse>
					</Grid>
					<ControlTemplate.Triggers>
						<Trigger Property="IsIndeterminate"
							Value="true" />
						<Trigger Property="IsIndeterminate"
							Value="false" />
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
</ResourceDictionary>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU Lesser General Public License (LGPLv3)


Written By
Founder
Hong Kong Hong Kong

Comments and Discussions