Recently managed to release a release of the library WPExtensions. The old working name of the library was not a very intelligible ShWP, and most of the library contains extensions and wrappers over standard controls.
Added support for package manager Nuget. Now you can install the library with the command:
Install-Package WPExtensionsYou can also download the library, source code and demo with
codeplex As usual, to use the library, you must add the appropriate namespace declaration:
')
xmlns: WPExtensions = "clr-namespace: WPExtensions; assembly = WPExtensions"
Next, we consider the main components of the library.
AdvancedApplicationBarAbout this component was already published in
HabréI will briefly repeat what it was and describe what's new in this version.
AdvancedApplicationBar is a wrapper over the standard ApplicationBar and adds several new features. Since it is implemented as a control, it must be placed inside the main container (usually a grid).
<phone:PhoneApplicationPage ...> <Grid x:Name="LayoutRoot" Background="Transparent"> ... <WPExtensions:AdvancedApplicationBar IsVisible="True" IsMenuEnabled="True"> <WPExtensions:AdvancedApplicationBarIconButton IconUri="/Images/appbar_button1.png" Text="Button 1"/> <WPExtensions:AdvancedApplicationBarIconButton IconUri="/Images/appbar_button2.png" Text="Button 2"/> <WPExtensions:AdvancedApplicationBarMenuItem Text="MenuItem 1"/> <WPExtensions:AdvancedApplicationBarMenuItem Text="MenuItem 2"/> </WPExtensions:AdvancedApplicationBar> </Grid> </phone:PhoneApplicationPage>
Please note that MenuItem does not need to be allocated to a separate tag.
Panorama / Pivot support.It is often required for different Panorama / Pivot items to display a different set of buttons / menus in the ApplicationBar. In msdn, a
solution is proposed with the creation of separate ApplicationBars in the resusre and change of the ApplicationBar when changing an Acting Item.
Here we can move the corresponding button inside the PanoramaItem / PivotItem in order to ensure that the button / menu is displayed only in this item (Button 1 / Menu item 1).
At the same time, the remaining menu buttons by default will be displayed AFTER all items. If it is necessary that the button / menu is displayed TO elements in the panorama, it is enough to move the menu / button TO the panorama (Button 2):
<phone:PhoneApplicationPage .... xmlns:WPExtensions="clr-namespace:WPExtensions;assembly=WPExtensions" ...> <Grid x:Name="LayoutRoot" Background="Transparent"> <WPExtensions:AdvancedApplicationBarIconButton IconUri="/Images/appbar_button2.png" Text="Button 2"/> <Grid x:Name="ContentPanel" Margin="12,0,12,0"> <controls:Panorama> <controls:PanoramaItem Header="Item1"> <Grid> ... <WPExtensions:AdvancedApplicationBarIconButton IconUri="/Images/appbar_button1.png" Text="Button 1"/> <WPExtensions:AdvancedApplicationBarMenuItem Text="MenuItem 1"/> </Grid> </controls:PanoramaItem> <controls:PanoramaItem Header="Item2"> ... </controls:PanoramaItem> </controls:Panorama> </Grid> <WPExtensions:AdvancedApplicationBar IsVisible="True" IsMenuEnabled="True"> <WPExtensions:AdvancedApplicationBarMenuItem Text="MenuItem 2"/> </WPExtensions:AdvancedApplicationBar> </Grid> </phone:PhoneApplicationPage>
Binding supportAs described last time, the AdvancedApplicationBar properties, unlike the original, support data binding.
<WPExtensions:AdvancedApplicationBarIconButton Text="{Binding AppBarIconButtonText}" IconUri="{Binding AppBarIconButtonText}" Visibility="{Binding Visibility}" Command="{Binding DeleteCommand}" CommandParameter="42" />
Support for updating the Binding for an item in focus.This is one of the innovations in the new version, especially useful with the active use of DataBinding.
Let us dwell on this point in more detail.
Suppose we have a TextBox with a Binding on the form.
<TextBox Text="{Binding Text,Mode=TwoWay}" />
And there is a corresponding Button on the form and a standard button <shell: ApplicationBarIconButton which in the handler display the text of the associated property in the MessageBox:
MessageBox.Show(Text);
If we are editing the text and are still in edit mode (focused in the TextBox) when clicking on ApplicationBarIconButton and clicking on Button we will see a different result. When you tap on ApplicationBarIconButton, you will see that the old text is displayed. This is due to the fact that the text is updated only when the focus is lost and the standard AppBar buttons do not lead to a loss of focus.
In AdvancedApplicationBar, the loss of focus is added when clicking on buttons (focus is transferred to the page) and we can see that the buttons will now work as expected and we will see the new text.
If necessary, you can return the default behavior attribute DisableLostFocus = "True"
<WPExtensions:AdvancedApplicationBarIconButton ... DisableLostFocus="True" />
Mode = "Default" IsVisible = "True"Another pair of ApplicationBar attributes that differ from the default values.
By default, the values of the Mode, IsVisible attributes in the ApplicationBar are set to Mode = "Default" IsVisible = "True"
In AdvancedApplicationBar, the value of these attributes is not fixed by default and depends on the following conditions:
If we have buttons on the page and / or PanoramaItem / PivotItem then the attribute values are Mode = "Default" IsVisible = "True"

If we only have menu items, then the attribute values are equal: Mode = "Minimized" IsVisible = "True"

If there is no menu button / menu item, attribute value IsVisible = “False”

This completes the AdvancedApplicationBar review. Next will be the TextBox Extensions descriptions.
TextBox ExtensionsQuite often we lack the basic TextBox functionality. I plan to expand the list of extensions in the future, but so far I have added two extensions to the library for the two most frequently encountered problems.
These extensions can be applied both to a separate element and to elements in a container (Page, StackPanel, Grid). For example, if we want to set the behavior for all text fields on a page, it is enough to add an attribute to the Page:
<phone:PhoneApplicationPage ... WPExtensions:Extensions.UpdateBindingOnChange="True" WPExtensions:Extensions.SelectAllOnFocus="True">
UpdateBindingOnChangeSuppose we have a text box associated with a particular model:
<TextBox Text="{Binding Text,Mode=TwoWay}" />
Quite often, it is necessary to update the model during a text change, usually for this in the TextChanged event the
Binding update is performed .
Now you can instead use the attribute: Extensions.UpdateBindingOnChange = "True"
<TextBox Text="{Binding Text,Mode=TwoWay}" WPExtensions:Extensions.UpdateBindingOnChange="True" />
SelectAllOnFocusYou can often see applications where you have to pre-erase the old value when editing values, such as price / quantity editing, etc ... For example, replace 10 with 20. You can significantly simplify the tedious procedure for the user by selecting the entire text field with the focus in the text field. The user can either leave the current value once more by tapping or replace the values simply by starting the set of the desired value.

For this, GotFocus is usually intercepted, where the txtBox.SelectAll () method is called.
Now we can set this behavior using the WPExtensions: Extensions.SelectAllOnFocus = “True” extension
<TextBox WPExtensions:Extensions.SelectAllOnFocus="True" />
MicrophoneWrapper microphone supportThe latest version 1.3 has added a wrapper over the microphone in the Audio namespace (WPExtensions.Audio)
Using the wrapper is also quite simple:
var microphoneWrapper=new MicrophoneWrapper();
Sound recording:
microphoneWrapper.Record();
Stop:
microphoneWrapper.Stop();
Sound reproduction:
microphoneWrapper.Play();
To get the recorded sound there are two methods:
getting a raw or original record:
microphoneWrapper.GetContent();
receiving record in wav format:
microphoneWrapper.GetWavContent();
I hope the library will be useful to someone, and I will be glad to any feedback.