Menu
  • HOME
  • TAGS

Pivot control header icon of un selected pivot in windows phone universal application

Tag: xaml,windows-phone-8.1,pivot

I have pivot control in my universal windows phone application. Defined like this

                <PivotItem.Header>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <Image Grid.Column="0" Margin="0 0 10 0" Width="40" Source="/Assets/Images/cher.png" />
                        <TextBlock x:Uid="cherTextBlock" Grid.Column="1" Style="{StaticResource PivotHeadingStyle}" />
                    </Grid>
                </PivotItem.Header>

When I am on first pivot the text of second pivot becomes dull. But offcourse the image doesn't become dull. I have same image with dull effect and I want that dul image to be shown when other pivot is shown.

One approach is that I make it programmatically and change the source of image when it is not in focus. But I want to know is that possible to do this in xaml or some other better approach than mine?

Best How To :

Accomplished it like programmatically

inside initialized component added this code

//RechargeAccountPivot is name of my pivot control.
RechargeAccountPivot.SelectionChanged += RechargeAccountPivot_SelectionChanged;

And this is selectionChanged event code. where i gave names to my all image controls and changed their icons.

private void RechargeAccountPivot_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        if (RechargeAccountPivot.SelectedIndex == 0)
        {
            PivotOneImage.Source = new BitmapImage(new Uri("ms-appx:///Assets/Images/BalanceTopUpIcons/rechargeCard.png"));// new BitmapImage { UriSource = new Uri("//Assets/Images/BalanceTopUpIcons/rechargeCard.png") };
            PivotTwoImage.Source = new BitmapImage(new Uri("ms-appx:///Assets/Images/BalanceTopUpIcons/eVoucherDull.png"));
            PivotThreeImage.Source = new BitmapImage(new Uri("ms-appx:///Assets/Images/BalanceTopUpIcons/eVoucherDull.png"));
        }
        else if (RechargeAccountPivot.SelectedIndex == 1)
        {
            PivotOneImage.Source = new BitmapImage(new Uri("ms-appx:///Assets/Images/BalanceTopUpIcons/rechargeCardDull.png"));
            PivotTwoImage.Source = new BitmapImage(new Uri("ms-appx:///Assets/Images/BalanceTopUpIcons/eVoucher.png"));
            PivotThreeImage.Source = new BitmapImage(new Uri("ms-appx:///Assets/Images/BalanceTopUpIcons/eVoucherDull.png"));
        }
        else
        {
            PivotOneImage.Source = new BitmapImage(new Uri("ms-appx:///Assets/Images/BalanceTopUpIcons/rechargeCardDull.png"));
            PivotTwoImage.Source = new BitmapImage(new Uri("ms-appx:///Assets/Images/BalanceTopUpIcons/eVoucherDull.png"));
            PivotThreeImage.Source = new BitmapImage(new Uri("ms-appx:///Assets/Images/BalanceTopUpIcons/eVoucher.png"));
        }
    }

unable to add reference to windows.media.speechsynthesis.dll

windows-phone-8.1,text-to-speech,system.windows.media

Look at MSDN, it is only supported in 8.1 XAML apps, not in 8.1 Silverlight apps.

Change the Location of DefaultPage in Universal App

c#,xaml,win-universal-app

First, you don't need to give different names to your files, use MainPage for both phone and pc project and put MainPage.xaml inside the view folder. The Universal App will be aware of which platforms it runs on and it will load the right page accordingly. You need to create...

How to get data from combobox from datagrid in WPF?

c#,wpf,xaml

I think you're confusing stuff. I assume you want your State items to have a string Measure property, and not a collection of them, but you want to be able to select the Measure value from a Combo with several options... If that's the case, then you should redefine your...

changing image background in button does not work

c#,windows-phone-8.1,.net-4.5

Set build action of images to content, use proper tags for your Uri, remove Relative URI. var uriString = bk1 ? @"ms-appx:/Assets/image1.png" : @"ms-appx:/Assets/image2.png"; k1.Background = new ImageBrush { ImageSource = new BitmapImage(new Uri(uriString)) }; ...

HorizontalContentAlignment does not appear

wpf,xaml

StackPanel has a property called as "FlowDirection". Is this what you are looking for? <StackPanel Orientation="Horizontal" DockPanel.Dock="Top" Background="Yellow" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0,2,2,0" Name="MainButtonsPanel" Width="400" FlowDirection="RightToLeft"> ...

Is it possible to concactenate a DataBound value with a constant string in XAML DataBinding?

c#,xaml,windows-phone

You can use a StringFormat in your binding, like so: <TextBox Text="{Binding ItemName, StringFormat={}Item: {0}}"/> That being said, it may cause some unexpected behavior when editing. For example, if the user edits only the item name (excluding the 'Item:' text), then when the TextBox loses focus, the string format will...

Custom WPF DataGrid with optional button column

c#,wpf,xaml,datagrid,custom-controls

I had to remove the section from the Generic.xaml style for the DataGrid to properly layout and created the column in code. protected override void OnInitialized(EventArgs e) { base.OnInitialized(e); CloneColumn.Visibility = ShowCloneColumn ? Visibility.Visible : Visibility.Hidden; } private DataGridTemplateColumn _cloneColumn; private DataGridTemplateColumn CloneColumn { get { if (_cloneColumn == null)...

ItemsSource bind to collection stays empty

c#,wpf,xaml,mvvm

In order to observe changes in a collection WPF provides the ObservableCollection class which implements INotifyCollectionChanged and INotifyPropertyChanged. Replace List<T> with ObservableCollection<T> and your code should work.

WPF bindings do not pick up any changes

c#,wpf,xaml,mvvm,inotifypropertychanged

You are not changing the value of the TestString, you are assigning a command to change the value but you do not seem to be executing it. this.RunCommand = new RelayCommand(this.RunAction); Bind that command to something or execute it manually from somewhere. Also you need to assign the property not...

Adding table header to Listview with DataTemplate in XAML

c#,wpf,xaml,listview,windows-runtime

If you have to use ListView then this is how it works: <ListView Margin="120,30,0,120" ItemsSource="{Binding MainViewModel}" Grid.Row="1"> <ListView.View> <GridView> <GridViewColumn DisplayMemberBinding="{Binding Data, Mode=TwoWay}" Width="100" Header="Column 1" /> <GridViewColumn DisplayMemberBinding="{Binding Year, Mode=TwoWay}" Width="100" Header="Column 2" /> <GridViewColumn DisplayMemberBinding="{Binding Month, Mode=TwoWay}" Width="100" Header="Column 3" /> <GridViewColumn...

How do you calculate pixel size of string?

c#,windows-phone-8.1,windows-8.1,windows-universal

I think you need to create a textblock in code and assign the desired text to it. Then you can get the actual height and width from it. See the below code TextBlock txt=new TextBlock(); //set additional properties of textblock here . Such as font size,font family, width etc. txt.Text...

Add image to the radio button

c#,wpf,xaml

This adds a picture to the background of your radio button. myRadioButton.Content = new Image() { Source = (new ImageSourceConverter()).ConvertFrom( "Images/pic.png") as ImageSource }; ...

Filtering ObservableCollection with ICollectionView

c#,wpf,xaml,mvvm,data-binding

You would need to: public class MainViewModel : ViewModelBase, IBarcodeHandler { public ICollectionView TraceItemCollectionView { get { return CollectionViewSource.GetDefaultView(TraceItemCollectionViewSource); } } public ObservableCollection<TraceDataItem> TraceItemCollectionViewSource { get; set; } } then, somewhere in the code (maybe in the constructor) add your filter: TraceItemCollectionView.Filter = o => { var item = (TraceDataItem)...

How to hide app bar button in different hub sections windows phone?

c#,xaml,windows-phone-8.1

If I understand right your question, you set Name property not in the right place. You should set it for AppBarButton element, not for SymbolIcon. I think your code should work after this changes. CommandBar x:Name="mybar" ClosedDisplayMode="Minimal" > <CommandBar.SecondaryCommands> <AppBarButton Label="setting" Click="AppBarButton_Click"/> </CommandBar.SecondaryCommands> <AppBarButton x:Uid="CALENDAR" x:Name="btnCalendar" Label="calendar" Click="AppBarButton_Click"> <AppBarButton.Icon> <SymbolIcon...

windows phone: deserialise and store both json key and value to modal

c#,windows-phone-8,windows-7,windows-phone-8.1,json-deserialization

public class Invoice { public string TF { get; set; } public string BF { get; set; } public string MD { get; set; } public string EFM { get; set; } public string ATT { get; set; } public string FPK { get; set; } } public class Example...

How can i make this CommandParameter work?

c#,wpf,xaml,binding,commandparameter

<Window x:Class="WpfApplication2.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mine="clr-namespace:WpfApplication2" Title="MainWindow" Height="350" Width="525"> <Grid> <mine:SquareControl Coordinates="{Binding VMCoordinates, Mode=TwoWay}"/> </Grid> </Window> In this case the namespace 'mine' is the namespace of your app. So in the main window the line inside the grid says "Place an instance of SquareControl in my view...

Checkbox checked event not firing in wpf

c#,wpf,xaml

Here is a simple example: <Window x:Class="CheckboxCheckedCommand.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"> <Grid> <CheckBox Content="Case Sensitive" Command="{Binding checkedCommand}"/> </Grid> Codebehind: public partial class MainWindow : Window { public ViewModel vm { get; set; } public MainWindow() { InitializeComponent(); vm = new ViewModel(); this.DataContext = vm; } }...

windows phone 8.1: Hide stackpanel if textblock is empty

c#,xaml,windows-phone-8,windows-phone-8.1,visualstatemanager

You can write converter to hide/show stackpanel public class BooleanToVisibilityConvertor: IValueConverter { public object Convert(object value, Type targetType, object parameter, string language) { if(value!=null) { if (!string.IsNullOrEmpty(value.ToString())) { return Visibility.Visible; } } return Visibility.Collapsed; } public object ConvertBack(object value, Type targetType, object parameter, string language) { throw new NotImplementedException(); }...

Slider progress bar with MediaElement Windows Phone 8.1

c#,xaml,slider,windows-phone-8.1,mediaelement

You are setting things up in the wrong order. Try changing it to this: if (listVmItem != null) { var file2 = await _finalStorageFolder.GetFileAsync(listVmItem.FileName); var stream = (await file2.OpenReadAsync()).AsStream().AsRandomAccessStream(); AudioPlayer.MediaOpened += AudioPlayer_MediaOpened; AudioPlayer.CurrentStateChanged += AudioPlayer_CurrentStateChanged; AudioPlayer.SetSource(stream, file2.ContentType); AudioPlayer.Play(); } and move these calls to the MediaOpened handler: TimeSpan recordingTime =...

Windows Phone 8.1 get image from base64 string

c#,image,windows-phone-8.1

I found a solution that works! var imageBytes = Convert.FromBase64String(base64String); using (InMemoryRandomAccessStream ms = new InMemoryRandomAccessStream()) { using (DataWriter writer = new DataWriter(ms.GetOutputStreamAt(0))) { writer.WriteBytes((byte[])imageBytes); writer.StoreAsync().GetResults(); } var image = new BitmapImage(); image.SetSource(ms); } Found the solution here: Load, show, convert image from byte array (database) in Windows Phone 8.1...

Get rid of Visual Studio Namespace error message

c#,.net,wpf,xaml,namespaces

It seems to me that your main application namespace is TreeViewTestC and not MyNameSpace. Therefore, you may well need to tell the compiler that your MyNameSpace is actually in the TreeViewTestC assembly, despite you only having a single project. Try using this instead: xmlns:MyTree="clr-namespace:MyNameSpace;assembly=TreeViewTestC" ...

Style vs inline property setting in silverlight with a custom control

c#,wpf,xaml,silverlight

That is not the correct way to register a dependency property. public bool UseCustomTooltips { get { return (bool)GetValue(UseCustomTooltipsProperty); } set { SetValue(UseCustomTooltipsProperty, value); } } public static readonly DependencyProperty UseCustomTooltipsProperty = DependencyProperty.Register("UseCustomTooltips", typeof(bool), typeof(MyControl), new PropertyMetadata(false, new PropertyChangedCallback(MyCallbackMethod))); Use the propdp snippet, it really is a beautiful thing....

Caching Views in XAML changes appearance?

xaml,caching,windows-store-apps

Does this make sense / improve performance of loading controls? Yes, it does make sense, however there are a few things to consider with this. Probably the most important thing is memory management. You need to consider how much memory you will be using when caching your views. Picture...

WrapPanel grabs focus from its children

c#,xaml,silverlight

Somehow its working fine for me. sharing the code snippet of what I tried. <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0"> <Image Name="img" Height="100" Width="100"/> <TextBox Name="tb3" Text="text2" KeyDown="tb3_KeyDown" Width="200"/> </Grid> <ScrollViewer Grid.Row="2"> <toolkit:WrapPanel Orientation="Vertical" Name="wp"> </toolkit:WrapPanel> </ScrollViewer> Adding textboxes from code behind TextBox tb2 = new TextBox(); // Constructor public MainPage() {...

BooleanToVisibilityConverter works on Textblock and not on UserControl

wpf,xaml,binding,windows-phone-8.1

The problem is the use of DataContext. Your MainPage has a DataContext : DataContext="{Binding Main, Source={StaticResource Locator}}" LoadingView also has a DataContext So, when you write this code : You try to find Test2 as a field in the DataContext of the LoadingView because you're in the same View. To...

C# XAML - How to add a combobox to some datagrid ROWS but not others?

c#,wpf,xaml,datagrid,combobox

Try using a DataTrigger with predefined DataTemplate items: <DataTemplate x:Key="OneItem" DataType="{x:Type ValueItem}" > <TextBox Text="{TemplateBinding Id}" /> </DataTemplate> <DataTemplate x:Key="MultiItems" DataType="{x:Type ValueItem}" > <ComboBox ItemsSource="{TemplateBinding ValueItems}" DisplayMemberPath="ValueName" SelectedValuePath="ID" SelectedValue="{TemplateBinding Id}" /> </DataTemplate> And then use a Content control to place the style accordingly. I haven't tried this but your data...

Setting App.xaml-resources' value from codebehind

c#,wpf,xaml

Color is a structure, which means it is passed by value, not by reference. You are basically making copies of the colors, modifying those copies, and then letting them go out of scope and get deleted. You should put the colors into the resource dictionary by doing something along the...

Overlapping Items in WPF ItemsControl

c#,wpf,xaml,user-interface,datatemplate

I found an answer that will work for my situation right here: http://stackoverflow.com/a/9687758/4912801 It turns out that setting the Panel.ZIndex property wasn't working because WPF inserts a ContentPresenter element for each item in the ItemsControl. In my application, I was trying to get whatever element the mouse is hovering over...

play audio periodically from a memory stream c#

c#,audio,windows-phone-8.1,memorystream

Here how I did it - just create a new SoundEffectInstance object and set it to the return value of SoundEffect.CreateInstance. https://msdn.microsoft.com/en-us/library/dd940203.aspx SoundEffect mySoundPlay = new SoundEffect(mStrm.ToArray(), 16000,AudioChannels.Mono); SoundEffectInstance instance = mySoundPlay.CreateInstance(); instance.IsLooped = true; instance.Play(); ...

Gracefully handling expected BindingExpression errors

wpf,xaml,data-binding,wpf-controls

Your 'null' item should simply be an item in your collection (of the same type as the rest of the items) that has no properties set, or at least no properties that are displayed. That way, you can avoid the Binding errors all together, because your 'null' item will have...

How to get info about previous page on Frame.GoBack()

c#,navigation,windows-phone-8.1

I think you should be able to do it by using Frame.ForwardStack property which holds forward navigation history. A short sample which should work: protected override void OnNavigatedTo(NavigationEventArgs e) { var lastPage = Frame.ForwardStack.LastOrDefault(); if (lastPage != null && lastPage.SourcePageType.Equals(typeof(desiredPage))) { /* do something */ } } ...

ViewModel Called on Navigation Back Prism MVVM Windows Phone 8.1 C#

c#,xaml,mvvm,windows-phone-8.1,prism

You're referring caching here. In the constructor of your ViewModel , set your NavigationCacheMode this.NavigationCacheMode = NavigationCacheMode.Required; and in OnNavigatedTo event handler , check your navigationMode and delete if you're doing something more than default initializing....

Single sign on single native client windows phone using ADAL

windows-phone-8.1,single-sign-on,adal

ADAL on Windows Phone does not use a WebView. It uses the WebAuthenticationBroker (WAB), a system API specifically designed to keep the cookie jar used during authentication isolated form the app itself. That prevents apps from using cookies to silently access protected resources without the user knowledge, while at the...

Aligning StackPanel to top-center in Canvas

c#,wpf,xaml,canvas

If you don't want any input or hit testing on a certain element you should set the IsHitTestVisible property to false: <Grid> <Canvas Name="Canvas" Background="#EFECCA"> <DockPanel VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Width="{Binding ActualWidth, ElementName=Canvas}" Height="{Binding ActualHeight, ElementName=Canvas}" MouseLeftButtonDown="DockPanel_MouseLeftButtonDown" TouchDown="DockPanel_TouchDown" Panel.ZIndex="2" Background="Transparent"> </DockPanel> <Button Width="50" Height="50"...

Items inside custom panel not getting arranged properly

c#,wpf,xaml

The solution was the easiest in the world. I need to use the NewsFeedPanel as ItemsPanel instead of a wrapPanel. Thanks Clemens for the suggestion.

Zoom into ListView contents without also scaling scroll bars

c#,wpf,xaml,scaletransform

You could use the always handy FindChild<T> function to retrieve the ScrollContentPresenter inside the ListView, and use your zooming function with it. public Control() { InitializeComponent(); this.Loaded += new RoutedEventHandler(Control_Loaded); } private void Control_Loaded(object sender, RoutedEventArgs e) { var presenter = FindChild<ScrollContentPresenter>(listView, null); var mouseWheelZoom = new MouseWheelZoom(presenter); PreviewMouseWheel +=...

Datagrid inside a Custom control is not updating

c#,wpf,xaml,datagrid

One minor mistake made by you in CustonDatagrid.xaml <DataGrid ItemsSource="{Binding ElementName=CustonDataGrid, Path=Colection}" DockPanel.Dock="Top"></DataGrid> There is no element called CustonDataGrid because of which the elements were never reflected. Changed it to <DataGrid ItemsSource="{Binding Path=Colection}"></DataGrid> I also made minor change in your MainWindow.cs public partial class MainWindow : Window { public MainWindow()...

WPF/XAML ResourceDictionary with blank space

c#,wpf,xaml

You can add xml:space="preserve" to your resource. This will, like it says, preserve the space. <System:String xml:space="preserve" x:Key="NumStartsTotal">Total: </System:String> More info here and here....

Backbutton press navigates to two page backward in Windows Phone App

c#,xaml,windows-phone-8

Add following line into the OnNavigatedFrom method: Windows.Phone.UI.Input.HardwareButtons.BackPressed -= HardwareButtons_BackPressed; In case the OnNavifatedFrom doesn't exist in your partial class of the XAML page, create it like bellow: protected override void OnNavigatedFrom(NavigationEventArgs e) { Windows.Phone.UI.Input.HardwareButtons.BackPressed -= HardwareButtons_BackPressed; } ...

Stream.CopyTo(newStream) return Length 0

audio,windows-phone-8.1,memorystream

I got the solution for the problem: do the following before calling CopyTo() mStrmStartDelimiter.Position = 0; mStrmEndDelimiter.Position = 0; ...

WPF Rotate an Image and align it

wpf,xaml,rotation,rendertransform

The problem is that the Transforms were applied after the layout pass. You should use a LayoutTransform to perform the transformation before the layout is calculated: <Image Name="ImageTarget" HorizontalAlignment="Left" VerticalAlignment="Top" Stretch="Uniform" RenderTransformOrigin=".5,.5"> <Image.LayoutTransform> <TransformGroup> <ScaleTransform ScaleX="{Binding Main.BindedViewMode, Converter={StaticResource ImageSizeConverter}}" /> <ScaleTransform ScaleY="{Binding Main.BindedViewMode,...

WPF expander not expanded above buttons make buttons unclickable

wpf,xaml,clickable,expander

I found a way of doing it, with code behind. I put my Expander in a Canvas and I added to my Expander two events: Expanded="searchMenuExpander_Expanded" and Collapsed="searchMenuExpander_Collapsed" which are defined as: private void searchMenuExpander_Expanded(object sender, RoutedEventArgs e) { Canvas.SetZIndex(searchMenuCanvas, 99); } private void searchMenuExpander_Collapsed(object sender, RoutedEventArgs e) { Canvas.SetZIndex(searchMenuCanvas,...

Enable drag/drop and reordering after long click on GridView control (XAML)

c#,xaml,windows-store-apps

After much fuss and chasing down events, I was able to get the intended effect on pen, mouse, and touch devices. The following code is not guaranteed to be the best way to accomplish the long click drag, but it is functioning on my devices with Windows 8.1. I encourage...

while Inherit style in WPF it affect parent style

c#,xaml,styles,wpf-controls

If you declare a Style without an x:Key, it will override the default style for that control. <Style TargetType="local:CustomControl"> So the code above will effect all CustomControl elements throughout the entire application (or within the scope). If you do not want to override the base style, you can give your...

Setting binding on usercontrol to mainwindow's ViewModel

.net,wpf,xaml,mvvm,data-binding

On your UserControl's code-behind (FilterTraceDataControl.xaml.cs), add a DependencyProperty, like this: public string Text { get { return (string)this.GetValue(TextProperty); } set { this.SetValue(TextProperty, value); } } public static readonly DependencyProperty TextProperty = DependencyProperty.Register( "Text", typeof(string), typeof(FilterTraceDataControl),new PropertyMetadata(null)); Then bind your UserControl's TextBox to it by RelativeSource or ElementName: <TextBox x:Name="PartNumbTextBox" Width="120"...