SSRS 2008 Adding PageBreak Before and within Subreport - ssrs-2008

I have a report with a Subreport. I want to add a pagebreak before the subreport. Also, the subreport has page breaks within that report but those breaks are not recognized when I run it as a subreport.
I would appreciate any guidance on this?

Add a rectangle between your subreports. Notice you can set page break settings in rectangle.
<SubReport1>...</SubReport1>
<Rectangle Name="RectanglePageBreak">
<ReportItems>
<Rectangle Name="RectanglePageBreak2">
<PageBreak>
<BreakLocation>End</BreakLocation>
</PageBreak>
<KeepTogether>true</KeepTogether>
<Height>0.05in</Height>
<Width>7.9in</Width>
<Visibility>
<Hidden>False</Hidden>
</Visibility>
<Style>
<Border>
<Style>None</Style>
</Border>
</Style>
</Rectangle>
</ReportItems>
<PageBreak>
<BreakLocation>End</BreakLocation>
</PageBreak>
<KeepTogether>true</KeepTogether>
<Top>1.79872in</Top>
<Height>0.05in</Height>
<Width>7.9in</Width>
<ZIndex>2</ZIndex>
<Visibility>
<Hidden>False</Hidden>
</Visibility>
<Style>
<Border>
<Style>None</Style>
</Border>
</Style>
</Rectangle>
<SubReport2>...</SubReport2>

Related

trying format a link in SSRS placeholder as currency

I'm trying to format a placeholder currency as a link colored blue and underlined so it shows to the user as a link, all I'm getting is black? and no underlining? when I export the report to excel it shows properly but through internet explorer version 11 its just black like the rest of the text? anybody have any ideas? magic wands?
<TablixCell>
<CellContents>
<Textbox Name="Measures_Extended_List_Price">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Fields!Extended_List_Price.Value</Value>
<Style>
<FontSize>9pt</FontSize>
<Format>$#,##0</Format>
<Color>Blue</Color> <--- does not render
</Style>
</TextRun>
</TextRuns>
<Style>
<TextAlign>Right</TextAlign>
</Style>
</Paragraph>
</Paragraphs>
<rd:DefaultName>Measures_Extended_List_Price</rd:DefaultName>
<ActionInfo>
<Actions>
<Action>
<Drillthrough>
<ReportName>Sales by Customer By Product Category</ReportName>
<Parameters>
<Parameter Name="pUserID">
<Value>=Parameters!pUserID.Value</Value>
</Parameter>
<Parameter Name="Month">
<Value>=Parameters!Month.Value</Value>
</Parameter>
<Parameter Name="FilterCustomer">
<Value>=Fields!Description.Value</Value>
</Parameter>
<Parameter Name="FilterTerritory">
<Value>=Parameters!FilterTerritory.Value</Value>
</Parameter>
</Parameters>
</Drillthrough>
</Action>
</Actions>
</ActionInfo>
<ZIndex>19</ZIndex>
<Style>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixCell>

WPF Cell Button Hide on certain condition

I have data source which, getting bind to grid in WPF. Data source is
array of students, with following fields
Name, Grade
Grid have 3 columns
Name, Grade, Settings
Settings column contains simple button for settings as below
<DataGridTemplateColumn Header="Settings" Width="75" CanUserResize="False">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button Name="cSettings" Click="cSettings_Click" Style="{DynamicResource EditSettingsButton}" Width="50" >
</Button>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
Now, If grade is equal to one then only,Settings Button should get displayed.
Can I write condition in XAML itself ? i.e. Visibility of button should be on some condition ?
Tried below approach but not working
<DataTemplate>
<Button Name="cSettings" Click="cSettings_Click" Style="{DynamicResource EditSettingsButton}" Width="50" >
<Style TargetType="{x:Type Button}">
<Style.Triggers>
<DataTrigger Binding="{Binding Grade}" Value="1">
<Setter Property="Visibility" Value="Visible"></Setter>
</DataTrigger>
<DataTrigger Binding="{Binding Grade}" Value="2">
<Setter Property="Visibility" Value="Hidden"></Setter>
</DataTrigger>
</Style.Triggers>
</Style>
</Button>
</DataTemplate>
Thanks
You could try using a converter instead. See this link

Interactive Sorting in a Reporting Services report with multiple groupings and toggles

Using Reporting Services 2008 r2.
In a Reporting Services report I have a table with two groupings: Group A and Group B. To show measures the Detail group is used.
The Group B is set to Toggle on a value in Group A.
Example: Group A is Car Makes and Group B is Car Models. In the details the Profit is shown. Initial only a list of Car Makes are shown with the possibility to expand (Toggle) and show Car Models. Thereby splitting the Profit into Car Models.
And now the problem. On the Profit Column the Interactive Sort feature is used to sort the values in the table with the 2 groups by Profit. So far I have only managed to sort either Group A or Group B. That is not what is wanted. What I want is to sort the whole table by Profit both Group A and Group B still maintaining the groupings.
Is this supported in Reporting Services?
Thanks in advance.
Report (.rdl) code example based on adventure works:
<?xml version="1.0" encoding="utf-8"?>
<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
<Body>
<ReportItems>
<Tablix Name="Tablix1">
<TablixBody>
<TablixColumns>
<TablixColumn>
<Width>2.5cm</Width>
</TablixColumn>
</TablixColumns>
<TablixRows>
<TablixRow>
<Height>0.6cm</Height>
<TablixCells>
<TablixCell>
<CellContents>
<Textbox Name="Textbox1">
<CanGrow>true</CanGrow>
<UserSort>
<SortExpression>=Fields!Gross_Profit.Value</SortExpression>
<SortExpressionScope>Subcategory</SortExpressionScope>
</UserSort>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>Gross Profit</Value>
<Style />
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox1</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixCell>
</TablixCells>
</TablixRow>
<TablixRow>
<Height>0.6cm</Height>
<TablixCells>
<TablixCell>
<CellContents>
<Textbox Name="Textbox13">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Sum(Fields!Gross_Profit.Value)</Value>
<Style>
<Format>#,0</Format>
</Style>
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox13</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixCell>
</TablixCells>
</TablixRow>
<TablixRow>
<Height>0.6cm</Height>
<TablixCells>
<TablixCell>
<CellContents>
<Textbox Name="Gross_Profit">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Fields!Gross_Profit.Value</Value>
<Style>
<Format>#,0</Format>
</Style>
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Gross_Profit</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixCell>
</TablixCells>
</TablixRow>
</TablixRows>
</TablixBody>
<TablixColumnHierarchy>
<TablixMembers>
<TablixMember />
</TablixMembers>
</TablixColumnHierarchy>
<TablixRowHierarchy>
<TablixMembers>
<TablixMember>
<TablixHeader>
<Size>2.5cm</Size>
<CellContents>
<Textbox Name="Textbox7">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>Category</Value>
<Style />
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox7</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixHeader>
<TablixMembers>
<TablixMember>
<TablixHeader>
<Size>2.5cm</Size>
<CellContents>
<Textbox Name="Textbox9">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>Subcategory</Value>
<Style />
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox9</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixHeader>
<TablixMembers>
<TablixMember />
</TablixMembers>
</TablixMember>
</TablixMembers>
<KeepWithGroup>After</KeepWithGroup>
</TablixMember>
<TablixMember>
<Group Name="Category">
<GroupExpressions>
<GroupExpression>=Fields!Category.Value</GroupExpression>
</GroupExpressions>
</Group>
<SortExpressions>
<SortExpression>
<Value>=Fields!Category.Value</Value>
</SortExpression>
</SortExpressions>
<TablixHeader>
<Size>2.5cm</Size>
<CellContents>
<Textbox Name="Category">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Fields!Category.Value</Value>
<Style />
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Category</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixHeader>
<TablixMembers>
<TablixMember>
<TablixHeader>
<Size>2.5cm</Size>
<CellContents>
<Textbox Name="Textbox12">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>Total</Value>
<Style />
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox12</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixHeader>
<KeepWithGroup>After</KeepWithGroup>
</TablixMember>
<TablixMember>
<Group Name="Subcategory">
<GroupExpressions>
<GroupExpression>=Fields!Subcategory.Value</GroupExpression>
</GroupExpressions>
</Group>
<SortExpressions>
<SortExpression>
<Value>=Fields!Subcategory.Value</Value>
</SortExpression>
</SortExpressions>
<TablixHeader>
<Size>2.5cm</Size>
<CellContents>
<Textbox Name="Subcategory">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Fields!Subcategory.Value</Value>
<Style />
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Subcategory</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
<rd:Selected>true</rd:Selected>
</CellContents>
</TablixHeader>
<TablixMembers>
<TablixMember>
<Group Name="Details" />
</TablixMember>
</TablixMembers>
<Visibility>
<Hidden>true</Hidden>
<ToggleItem>Category</ToggleItem>
</Visibility>
</TablixMember>
</TablixMembers>
</TablixMember>
</TablixMembers>
</TablixRowHierarchy>
<DataSetName>DataSet1</DataSetName>
<Height>1.8cm</Height>
<Width>7.5cm</Width>
<Style>
<Border>
<Style>None</Style>
</Border>
</Style>
</Tablix>
</ReportItems>
<Height>0.70866in</Height>
<Style />
</Body>
<Width>2.95276in</Width>
<Page>
<PageHeight>29.7cm</PageHeight>
<PageWidth>21cm</PageWidth>
<LeftMargin>2cm</LeftMargin>
<RightMargin>2cm</RightMargin>
<TopMargin>2cm</TopMargin>
<BottomMargin>2cm</BottomMargin>
<ColumnSpacing>0.13cm</ColumnSpacing>
<Style />
</Page>
<AutoRefresh>0</AutoRefresh>
<DataSources>
<DataSource Name="DataSource1">
<DataSourceReference>DataSource1</DataSourceReference>
<rd:SecurityType>None</rd:SecurityType>
<rd:DataSourceID>9a3c3555-b858-4735-8414-0856ebe26806</rd:DataSourceID>
</DataSource>
</DataSources>
<DataSets>
<DataSet Name="DataSet1">
<Query>
<DataSourceName>DataSource1</DataSourceName>
<CommandText> SELECT NON EMPTY { [Measures].[Gross Profit] } ON COLUMNS, NON EMPTY { ([Product].[Category].[Category].ALLMEMBERS * [Product].[Subcategory].[Subcategory].ALLMEMBERS ) } DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS FROM [Adventure Works] CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS</CommandText>
<rd:DesignerState>
<QueryDefinition xmlns="http://schemas.microsoft.com/AnalysisServices/QueryDefinition">
<CommandType>MDX</CommandType>
<QuerySpecification xsi:type="MDXQuerySpecification" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Select>
<Items>
<Item>
<ID xsi:type="Level">
<DimensionName>Product</DimensionName>
<HierarchyName>Category</HierarchyName>
<HierarchyUniqueName>[Product].[Category]</HierarchyUniqueName>
<LevelName>Category</LevelName>
<UniqueName>[Product].[Category].[Category]</UniqueName>
</ID>
<ItemCaption>Category</ItemCaption>
<UniqueName>true</UniqueName>
</Item>
<Item>
<ID xsi:type="Level">
<DimensionName>Product</DimensionName>
<HierarchyName>Subcategory</HierarchyName>
<HierarchyUniqueName>[Product].[Subcategory]</HierarchyUniqueName>
<LevelName>Subcategory</LevelName>
<UniqueName>[Product].[Subcategory].[Subcategory]</UniqueName>
</ID>
<ItemCaption>Subcategory</ItemCaption>
<UniqueName>true</UniqueName>
</Item>
<Item>
<ID xsi:type="Measure">
<MeasureName>Gross Profit</MeasureName>
<UniqueName>[Measures].[Gross Profit]</UniqueName>
</ID>
<ItemCaption>Gross Profit</ItemCaption>
<BackColor>true</BackColor>
<ForeColor>true</ForeColor>
<FontFamily>true</FontFamily>
<FontSize>true</FontSize>
<FontWeight>true</FontWeight>
<FontStyle>true</FontStyle>
<FontDecoration>true</FontDecoration>
<FormattedValue>true</FormattedValue>
<FormatString>true</FormatString>
</Item>
</Items>
</Select>
<From>Adventure Works</From>
<Filter>
<FilterItems />
</Filter>
<Calculations />
<Aggregates />
<QueryProperties />
</QuerySpecification>
<Query>
<Statement> SELECT NON EMPTY { [Measures].[Gross Profit] } ON COLUMNS, NON EMPTY { ([Product].[Category].[Category].ALLMEMBERS * [Product].[Subcategory].[Subcategory].ALLMEMBERS ) } DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS FROM [Adventure Works] CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS</Statement>
<ParameterDefinitions />
</Query>
</QueryDefinition>
</rd:DesignerState>
</Query>
<Fields>
<Field Name="Category">
<DataField><?xml version="1.0" encoding="utf-8"?><Field xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="Level" UniqueName="[Product].[Category].[Category]" /></DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="Subcategory">
<DataField><?xml version="1.0" encoding="utf-8"?><Field xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="Level" UniqueName="[Product].[Subcategory].[Subcategory]" /></DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="Gross_Profit">
<DataField><?xml version="1.0" encoding="utf-8"?><Field xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:type="Measure" UniqueName="[Measures].[Gross Profit]" /></DataField>
<rd:TypeName>System.Int32</rd:TypeName>
</Field>
</Fields>
</DataSet>
</DataSets>
<rd:ReportUnitType>Cm</rd:ReportUnitType>
<rd:ReportID>73334590-ae11-454b-8075-9d8b167ac594</rd:ReportID>
</Report>
Yes, you can do this, you should add one more dummy parent group (parent for GroupA and for GroupB) which will have grouping by group fields from group A and group fields from B. And than in interactive sorting you should choose this group.
In you report you have group Category and Subcategory, add also ParentGroup (grouping fields are Category, Subcategory):
And delete unnesessary cells which are created by this group.

Styling button in MVVM

I am writing a small WPF application using MVVM pattern.
I set some style resources for buttons into my main window and I would like them to apply to the buttons into the views. The problem is that some of the buttons are having a style with trigger. So I would like to inherit this style from the generic one
here is my main window code:
<Window.Resources>
<DataTemplate DataType="{x:Type vm:HomeViewModel}">
<views:HomeView/>
</DataTemplate>
<DataTemplate DataType="{x:Type vm:DetailReportViewModel}">
<views:DetailReportView/>
</DataTemplate>
<DataTemplate DataType="{x:Type vm:TransferViewModel}">
<views:TransferView/>
</DataTemplate>
<Style TargetType="{x:Type Button}">
<Setter Property="Margin" Value="5"/>
<Setter Property="MinWidth" Value="30"/>
<Setter Property="Foreground" Value="Red"/>
</Style>
<Style TargetType="{x:Type ComboBox}">
<Setter Property="Margin" Value="5"/>
</Style>
</Window.Resources>
here is the button XAML into my view/usercontrol
<Button Content="Delete" Command="{Binding DeleteReportCommand}">
<Button.Style>
<Style TargetType="{x:Type Button}">
<Style.Triggers>
<DataTrigger Binding="{Binding Mode}">
<DataTrigger.Value>
<vm:Mode>Add</vm:Mode>
</DataTrigger.Value>
<Setter Property="Visibility" Value="Collapsed"/>
</DataTrigger>
<DataTrigger Binding="{Binding Mode}">
<DataTrigger.Value>
<vm:Mode>Edit</vm:Mode>
</DataTrigger.Value>
<Setter Property="Visibility" Value="Visible"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
I tried to used BasedOn="{StaticResource {x:Type Button} to inherit but it doesn't seems to work (see img)
I tried with a key name but static resource won't find the key name as it's not on the same view. And BasedOn is not accepting Dynamic resource.
Anything I am missing?
Thank you
You can put all the custom styles in a separate resource dictionary file and you can add it in usercontrol.resources.
Refer this: http://www.codeproject.com/Articles/35346/Using-a-Resource-Dictionary-in-WPF
Or you can put all those in app.xaml (Application.Resources).
Refer this: http://msdn.microsoft.com/en-us/library/system.windows.resourcedictionary.aspx

WPF/C#: 'Slide to Unlock' feature from iPhone

I just want to ask for your opinion on how to achieve the 'Slide to Unlock' feature from iPhone using Windows Presentation Foundation.
I already came across to this article: iPhone slide to unlock progress bar (part 1), and wondering if you can give me some other resources for a good head start. Thank you.
I would retemplate a Slider, as this is the closest control, functionality-wise.
You should catch the event of Value_Changed, and if Value == Maximum then the slider is "opened".
Retemplating the control would make it look like your "unlock control" with ease. I'll paste later an example.
-- EDIT --
Have free time at work, so I started it for you.
The usage is as follows:
<Grid x:Name="LayoutRoot">
<Slider Margin="185,193,145,199" Style="{DynamicResource SliderStyle1}"/>
</Grid>
and the ResourceDictionary:
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d">
<LinearGradientBrush x:Key="MouseOverBrush" EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#FFF" Offset="0.0"/>
<GradientStop Color="#AAA" Offset="1.0"/>
</LinearGradientBrush>
<LinearGradientBrush x:Key="LightBrush" EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#FFF" Offset="0.0"/>
<GradientStop Color="#EEE" Offset="1.0"/>
</LinearGradientBrush>
<LinearGradientBrush x:Key="NormalBorderBrush" EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#CCC" Offset="0.0"/>
<GradientStop Color="#444" Offset="1.0"/>
</LinearGradientBrush>
<Style x:Key="SimpleScrollRepeatButtonStyle" d:IsControlPart="True" TargetType="{x:Type RepeatButton}">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="IsTabStop" Value="false"/>
<Setter Property="Focusable" Value="false"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type RepeatButton}">
<Grid>
<Rectangle Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="{TemplateBinding BorderThickness}"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="ThumbStyle1" d:IsControlPart="True" TargetType="{x:Type Thumb}">
<Setter Property="SnapsToDevicePixels" Value="true"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Thumb}">
<Grid Width="54">
<Ellipse x:Name="Ellipse" />
<Border CornerRadius="10" >
<Border.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FFFBFBFB" Offset="0.075"/>
<GradientStop Color="Gainsboro" Offset="0.491"/>
<GradientStop Color="#FFCECECE" Offset="0.509"/>
<GradientStop Color="#FFA6A6A6" Offset="0.943"/>
</LinearGradientBrush>
</Border.Background>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Fill" Value="{StaticResource MouseOverBrush}" TargetName="Ellipse"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Fill" Value="{StaticResource DisabledBackgroundBrush}" TargetName="Ellipse"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="SliderStyle1" TargetType="{x:Type Slider}">
<Setter Property="Background" Value="{StaticResource LightBrush}"/>
<Setter Property="BorderBrush" Value="{StaticResource NormalBorderBrush}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Slider}">
<Border CornerRadius="14" Padding="4">
<Border.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FF252525" Offset="0"/>
<GradientStop Color="#FF5C5C5C" Offset="1"/>
</LinearGradientBrush>
</Border.Background>
<Grid x:Name="GridRoot">
<TextBlock Text="Slide to unlock" HorizontalAlignment="Center" VerticalAlignment="Center" />
<!-- TickBar shows the ticks for Slider -->
<!-- The Track lays out the repeat buttons and thumb -->
<Track x:Name="PART_Track" Height="Auto">
<Track.Thumb>
<Thumb Style="{StaticResource ThumbStyle1}"/>
</Track.Thumb>
<Track.IncreaseRepeatButton>
<RepeatButton Style="{StaticResource SimpleScrollRepeatButtonStyle}" Command="Slider.IncreaseLarge" Background="Transparent"/>
</Track.IncreaseRepeatButton>
<Track.DecreaseRepeatButton>
<RepeatButton Style="{StaticResource SimpleScrollRepeatButtonStyle}" Command="Slider.DecreaseLarge" d:IsHidden="True"/>
</Track.DecreaseRepeatButton>
</Track>
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="TickPlacement" Value="TopLeft"/>
<Trigger Property="TickPlacement" Value="BottomRight"/>
<Trigger Property="TickPlacement" Value="Both"/>
<Trigger Property="IsEnabled" Value="false"/>
<!-- Use a rotation to create a Vertical Slider form the default Horizontal -->
<Trigger Property="Orientation" Value="Vertical">
<Setter Property="LayoutTransform" TargetName="GridRoot">
<Setter.Value>
<RotateTransform Angle="-90"/>
</Setter.Value>
</Setter>
<!-- Track rotates itself based on orientation so need to force it back -->
<Setter TargetName="PART_Track" Property="Orientation" Value="Horizontal"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
Note that this is a very good start, but it's not everything.
I would also define a custom control that derives from slider and that uses this style automatically. Also I would expose a SlideUnlocked event when the user slides all the way right.
To finish it all i would also add an animation that moves the Thumb back left in case the user has dragged it right, but not all the way (to imitate iPhone's UX exactly.)
Good luck, and ask away if you don't know how to implement any of the stages i suggested.
WPF slider has got one "-" and it is value ,
always when you move it, value is for example in decimal 1,122213174 so one "-".
But another way to create slider is in Windows forms.
Create trackBar1 ,and maximum = 100 points.
This is for Windows forms application:
On trackBar1_mouse_up:
if(trackBar1.Value < 100)
{
//Animation - slide back dynamicaly.
for(int i=0;i<=trackBar1.Value;i++){
int secondVal=trackBar1.Value-i;
trackBar1.Value=secondVal;
System.Threading.Thread.Sleep(15);
}
}
if(trackBar1.Value==100)
{
//sets enabled to false, then after load cannot move it.
trackBar1.Enabled=false;
MessageBox.Show("Done!");
}
And this for WPF Slider: (on PreviewMouseUp)
if (Convert.ToInt16(slider1.Value) < 99)
{
//Animation - slide back dynamicaly.
for (int i = 0; i < Convert.ToInt16(slider1.Value); i++)
{
int secondVal = Convert.ToInt32(slider1.Value) - i;
slider1.Value = secondVal;
System.Threading.Thread.Sleep(10);
if (secondVal < 2)
{
slider1.Value = 0;
}
}
}
if (Convert.ToInt16(slider1.Value) > 99)
{
//sets enabled to false, then after load cannot move it.
slider1.IsEnabled = false;
slider1.Value = 100;
MessageBox.Show("Done!");
}
Good luck! I hope it helps, try it with slider, but I think application will crash.