Skip to content
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
24d0431
feat(InAppNotification): first version of the control
Odonno Jul 25, 2017
a712c30
feat(InAppNotification): add animations
Odonno Jul 25, 2017
2babc22
feat(inAppNotification): add ability to use DataTemplate
Odonno Jul 25, 2017
b9709df
feat(InAppNotification): set responsive design for DataTemplate with …
Odonno Jul 26, 2017
a201546
docs(InAppNotification): add bind files
Odonno Jul 26, 2017
019a3dd
docs(InAppNotification): add markdown file
Odonno Jul 26, 2017
e142ec4
docs(InAppNotification): add link from readme file
Odonno Jul 26, 2017
208a650
feat(InAppNotification): add ability to hide dismiss button
Odonno Jul 28, 2017
682143d
docs(InAppNotification): add example with drop shadow
Odonno Jul 28, 2017
62eff8b
docs(InAppNotification): add vscode-like notification example
Odonno Jul 28, 2017
e1e2a45
feat(InAppNotification): show notification with duration
Odonno Jul 29, 2017
f3a2c49
docs(InAppNotification): remove default template explanation
Odonno Jul 29, 2017
4ab647d
merge
Odonno Aug 12, 2017
85b5da1
fix(inAppNotification): remove the use of converter
Odonno Aug 12, 2017
1ecc520
docs(InAppNotification): add ability to show or hide dismiss button i…
Odonno Aug 12, 2017
b78f3d4
fix(InAppNotification): set dismiss button visiblity after null check
Odonno Aug 17, 2017
8846f3d
docs(InAppNotification): add popup animation explanation
Odonno Aug 17, 2017
0a3c40d
fix(InAppNotification): set correct animation the first time visibili…
Odonno Aug 17, 2017
2b7ac18
docs(InAppNotifications): add note about the render priority
Odonno Aug 21, 2017
ac85365
fix(InAppNotifications): simplify code bind file using a non responsi…
Odonno Aug 21, 2017
8fe1df5
merge
Odonno Aug 22, 2017
f4c6902
refactor(InAppNotifications): use return instead of async keyword on …
Odonno Aug 22, 2017
5fb2211
docs(InAppNotifications): use Shell to register commands in the sampl…
Odonno Aug 23, 2017
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Microsoft.Toolkit.Uwp.SampleApp/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
<SolidColorBrush x:Key="Brush-Blue-01"
Color="{StaticResource Blue-01}" />

<!-- Converters -->
<converters:BoolNegationConverter x:Key="BoolNegationConverter" />

<!-- Styles -->
<Style TargetType="TextBlock">
<Setter Property="Foreground" Value="{StaticResource Brush-Grey-01}" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@
<Content Include="SamplePages\HeaderedTextBlock\HeaderedTextBlock.png" />
<Content Include="SamplePages\ImageCache\ImageEx.png" />
<Content Include="SamplePages\ImageEx\ImageEx.png" />
<Content Include="SamplePages\InAppNotification\InAppNotification.png" />
<Content Include="SamplePages\Incremental Loading Collection\icon.png" />
<Content Include="SamplePages\Light\LightBehavior.png" />
<Content Include="SamplePages\LinkedIn Service\LinkedInLogo.png" />
Expand Down Expand Up @@ -399,6 +400,8 @@
<Content Include="SamplePages\BluetoothLEHelper\BluetoothLEHelperCode.bind" />
<Content Include="SamplePages\OrbitView\OrbitViewXaml.bind" />
<Content Include="SamplePages\Menu\Menu.bind" />
<Content Include="SamplePages\InAppNotification\InAppNotificationCode.bind" />
<Content Include="SamplePages\InAppNotification\InAppNotificationXaml.bind" />
<Content Include="SamplePages\ListViewBase\ListViewBaseCode.bind" />
</ItemGroup>
<ItemGroup>
Expand All @@ -420,6 +423,9 @@
<Compile Include="SamplePages\BluetoothLEHelper\BluetoothLEHelperPage.xaml.cs">
<DependentUpon>BluetoothLEHelperPage.xaml</DependentUpon>
</Compile>
<Compile Include="SamplePages\InAppNotification\InAppNotificationPage.xaml.cs">
<DependentUpon>InAppNotificationPage.xaml</DependentUpon>
</Compile>
<Compile Include="SamplePages\ListViewBase\ListViewBasePage.xaml.cs">
<DependentUpon>ListViewBasePage.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -680,6 +686,10 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="SamplePages\InAppNotification\InAppNotificationPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="SamplePages\ListViewBase\ListViewBasePage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
// ## XAML - Text + buttons (DataTemplate)

<DataTemplate x:Key="InAppNotificationWithButtonsTemplate">
<UserControl>
<Grid DataContext="{Binding ElementName=CurrentPage}">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup>
<VisualState x:Name="NarrowState">
<VisualState.Setters>
<Setter Target="TextBlock.(Grid.RowSpan)" Value="1" />
<Setter Target="TextBlock.(Grid.ColumnSpan)" Value="2" />

<Setter Target="ButtonsStackPanel.(Grid.Row)" Value="1" />
<Setter Target="ButtonsStackPanel.(Grid.RowSpan)" Value="1" />
<Setter Target="ButtonsStackPanel.(Grid.Column)" Value="0" />
<Setter Target="ButtonsStackPanel.(Grid.ColumnSpan)" Value="2" />
<Setter Target="ButtonsStackPanel.Orientation" Value="Vertical" />
<Setter Target="ButtonsStackPanel.Margin" Value="0 5 0 0" />

<Setter Target="YesButton.Width" Value="Auto" />
<Setter Target="YesButton.HorizontalAlignment" Value="Stretch" />

<Setter Target="NoButton.Width" Value="Auto" />
<Setter Target="NoButton.HorizontalAlignment" Value="Stretch" />
<Setter Target="NoButton.Margin" Value="0 5 0 0" />
</VisualState.Setters>

<VisualState.StateTriggers>
<StateTrigger IsActive="{Binding IsRootGridActualWidthLargerThan700, Converter={StaticResource BoolNegationConverter}, Mode=OneWay}" />
</VisualState.StateTriggers>
</VisualState>

<VisualState x:Name="LargeState">
<VisualState.StateTriggers>
<StateTrigger IsActive="{Binding IsRootGridActualWidthLargerThan700, Mode=OneWay}" />
</VisualState.StateTriggers>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>

<Grid x:Name="RootGrid" SizeChanged="RootGrid_SizeChanged">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the SizeChanged event?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not remember, I think this is a old version. Will update it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. I remember. I made it that way to be able to detect the change of the Grid Width (not the App Width) so I can create a StateTrigger based on the container Size, not the App Size.

I do not know if there is a better option because it will crash if you do not have this code in your code-behind:

public bool IsRootGridActualWidthLargerThan700 { get; set; } private void RootGrid_SizeChanged(object sender, SizeChangedEventArgs e) { // When the root part size of the In App Notification template changed, we should apply VisualState bool newValue = e.NewSize.Width > 700; if (IsRootGridActualWidthLargerThan700 != newValue) { IsRootGridActualWidthLargerThan700 = newValue; OnPropertyChanged(nameof(IsRootGridActualWidthLargerThan700)); } } 
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that required for an example? Should it work without it?

Copy link
Contributor Author

@Odonno Odonno Aug 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be clear, the DataTemplate available in the bind code file is a specific template that handle responsive design based on the container Width. And to make it work, I need a property that tell what StateTrigger I should use, in this case I used a boolean in the code behind.

Of course, it is not the default behavior and you can perfectly use the control without extra code :

<controls:InAppNotification x:Name="ExampleInAppNotification" /> 

And then use .ShowAsync() method.

My objective with the DataTemplate was to provide a more complete example that mimic MS Edge notification with buttons (Horizontal Orientation when Width > 700px, Vertical Orientation otherwise).

Should I remove this template from the code file?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My thoughts on this are to have a simple template that doesn't complicate the mechanics of the control and shows the minimum needed to try the control. We could always have both?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nmetulev I can leave the complete Templates in the page (with buttons, with DropShadow, etc..) and add a simple template in the code file. I'll update it.

<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>

<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>

<TextBlock x:Name="TextBlock" Grid.RowSpan="2"
Text="Do you like it?" VerticalAlignment="Center" />

<StackPanel x:Name="ButtonsStackPanel" Grid.RowSpan="2" Grid.Column="1"
Orientation="Horizontal" VerticalAlignment="Center">
<Button x:Name="YesButton" Content="Yes" Width="150" Height="30" Click="YesButton_Click" />
<Button x:Name="NoButton" Content="No" Width="150" Height="30" Margin="10 0 0 0" Click="NoButton_Click" />
</StackPanel>
</Grid>
</Grid>
</UserControl>
</DataTemplate>

// ## XAML - Control placed where you want the notification to appear

<controls:InAppNotification x:Name="ExampleInAppNotification" />

// ## C# - Show and dismiss the in app notification

// Show notification with simple text (and a duration of 2 seconds)
int duration = 2000;
await ExampleInAppNotification.ShowAsync("Some text.", duration);

// Show notification using a DataTemplate
object inAppNotificationWithButtonsTemplate;
bool isTemplatePresent = Resources.TryGetValue("InAppNotificationWithButtonsTemplate", out inAppNotificationWithButtonsTemplate);

if (isTemplatePresent && inAppNotificationWithButtonsTemplate is DataTemplate)
{
await ExampleInAppNotification.ShowAsync(inAppNotificationWithButtonsTemplate as DataTemplate);
}

// Dismiss notification
ExampleInAppNotification.Dismiss();
Loading