I don't know how to use triggers in xaml of windows phone 8.
But I have seen some people do it, like below:
<toolkit:ListPicker Header="Background"
ExpansionMode="FullscreenOnly"
Template="{StaticResource ListPickerControlTemplate}"
VerticalAlignment="Top"
ItemsSource="{Binding Path=Buildings.ObjectList}"
Margin="0"
x:Name="buldings"
Padding="0">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction Command="{Binding Path=BuildingSelectionCommand}"
CommandParameter="{Binding Path=SelectedItem, ElementName=buldings}" />
</i:EventTrigger>
</i:Interaction.Triggers>
But I don't have System.Windows.Interactivity.
And I failed to find a compatible package through Nuget.
Thanks for your patience.
Right click on References -> Add Reference.. -> Extensions -> Select
System.Windows.Interactivity
The assembly resides here:
C:\Program Files (x86)\Microsoft SDKs\Expression\Blend\Windows
Phone\v8.0\Libraries\
Related
I'd really like to use RelativePanel in a UWP app I'm writing, to simplify visual state.
This is what I want
I've tried to achieve this with the following XAML:
<RelativePanel>
<TextBlock x:Name="Title" Height="50" Margin="15" FontSize="24"
RelativePanel.AlignTopWithPanel="True"
RelativePanel.AlignLeftWithPanel="True"
RelativePanel.AlignRightWithPanel="True">
</TextBlock>
<TextBox x:Name="Editor" Margin="15" Padding="20" HorizontalAlignment="Stretch"
RelativePanel.AlignLeftWithPanel="True"
RelativePanel.Below="Title"
RelativePanel.RightOf="FileList">
</TextBox>
<ListView x:Name="FileList" HorizontalAlignment="Stretch" Margin="15"
RelativePanel.AlignRightWithPanel="True"
RelativePanel.Below="Title">
</ListView>
</RelativePanel>
This isn't working. Editor does not stretch. If I set Editor to RelativePanel.AlignRightWith="FilesList", it stretches past files list and fills the window.
Is there any way to do what I want with RelativePanel? Please don't post suggestions on how to do this in Grid, I can already do that - I want to use RelativePanel in this case
Your Editor control should have -
RelativePanel.AlignLeftWithPanel="True"
RelativePanel.Below="Title"
RelativePanel.LeftOf="FileList"
RelativePanel.AlignBottomWithPanel="True"
Note it should be LeftOf, not RightOf. You will also need AlignBottomWithPanel set to True.
The code below under the Windows Phone 8.1 Silverlight works like a charm
<i:Interaction.Triggers>
<i:EventTrigger EventName="Loaded">
<interactivity:EventToCommand Command="{Binding ApplyCommand}"
DisableAssociatedObjectOnCannotExecute="True"
PassEventArgsToCommand="True" />
</i:EventTrigger>
</i:Interaction.Triggers>
Is exist any way to work under Universal Application (Windows 10)?
EventToCommand is not available in UWP (WinRT). You can (or should) use this instead:
1.Install the Behaviors sdk via NuGet
2.Use this code
<Interactivity:Interaction.Behaviors>
<Core:EventTriggerBehavior EventName="Loaded">
<Core:InvokeCommandAction Command="{Binding ApplyCommand}" />
</Core:EventTriggerBehavior>
</Interactivity:Interaction.Behaviors>
Had this error a few days ago and it seemed to go away. Now it wont go away. I am also getting an Adcontrol error: ApplicationId and AdUnitId need to be set before using this control Adcontrol is set up the exact same way in another app so I don't see what the issue is and cant find any information on it.
EDIT:
If I remove the portion of the code with double brackets }}, the Invalid Error goes away. I removed the Adcontrol all together to isolate the error as well. However, when I run the app, I still get this:
**A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.ni.dll
Additional information: Could not load file or assembly 'Microsoft.Phone.Controls.Toolkit.resources, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.**
I have uninstalled and reinstalled WPToolkit. Im using similar code and WPToolkit in another app and it does not give me this error. What else can I do?
INVALID XAML:
<DataTemplate x:Key="SoundTileDataTemplate">
<StackPanel>
<Grid Margin="0,5,6,0" Height="100" Width="140"
toolkit:TiltEffect.IsTiltEnabled="True">
<Border BorderBrush="#FF49A609" BorderThickness="1" CornerRadius="3,3,3,3" Background="{StaticResource PhoneAccentBrush}" Opacity=".6"/>
<TextBlock Text="{Binding Title}" FontSize="19" TextWrapping="Wrap" Width="140" FontFamily="/BBSM;component/Fonts/123Sketch.ttf#123Sketch" TextAlignment="Center" />
<Image Source="/Assets/tiles/TRXHSBRGIcon.png" Width="30" VerticalAlignment="Bottom" HorizontalAlignment="Right" Margin="0,0,6,6" Visibility="{Binding Status, Converter={StaticResource DownloadStatusToIconVisibilityConverter}}" />
<ProgressBar Height="12" VerticalAlignment="Bottom" Padding="0" Margin="0" Foreground="{StaticResource PhoneForegroundBrush}" Value="{Binding DownloadProgress}" Visibility="{Binding Status, Converter={StaticResource DownloadStatusToProgressBarVisibilityConverter}}"/>
</Grid>
</StackPanel>
</DataTemplate>
<DataTemplate x:Key="ExtrasTileDataTemplate">
<StackPanel>
<toolkit:ContextMenuService.ContextMenu>
<toolkit:ContextMenu IsZoomEnabled="False" >
<toolkit:MenuItem Header="Save as Ringtone" Command="{Binding SaveSoundAsRingtone}" CommandParameter="{Binding FilePath}" />
</toolkit:ContextMenu>
</toolkit:ContextMenuService.ContextMenu>
<Grid Margin="0,5,6,0" Height="100" Width="140"
toolkit:TiltEffect.IsTiltEnabled="True">
<Border BorderBrush="#FF49A609" BorderThickness="1" CornerRadius="3,3,3,3" Background="{StaticResource PhoneAccentBrush}" Opacity=".6"/>
<TextBlock Text="{Binding Title}" FontSize="19" TextWrapping="Wrap" Width="140" FontFamily="/BBSM;component/Fonts/123Sketch.ttf#123Sketch" TextAlignment="Center" />
<Image Source="/Assets/tiles/TRXHSBRGIcon.png" Width="30" VerticalAlignment="Bottom" HorizontalAlignment="Right" Margin="0,0,6,6" Visibility="{Binding Status, Converter={StaticResource DownloadStatusToIconVisibilityConverter}}" />
<ProgressBar Height="12" VerticalAlignment="Bottom" Padding="0" Margin="0" Foreground="{StaticResource PhoneForegroundBrush}" Value="{Binding DownloadProgress}" Visibility="{Binding Status, Converter={StaticResource DownloadStatusToProgressBarVisibilityConverter}}"/>
</Grid>
</StackPanel>
</DataTemplate>
Adcontrol:
<UI:AdControl ApplicationId="*********" AdUnitId="******" Width="480" IsAutoRefreshEnabled="True" Grid.Row="1" Height="80"/>
When I run the project I get the following. I continue after each one, and the app runs, but the Pivot Headers are all screwed up but app seems functional.
A first chance exception of type 'Microsoft.Advertising.Shared.AdException' occurred in Microsoft.Advertising.Mobile.DLL
Additional information: You can not use PubCenter IDs for testing in the emulator. If you want to test with these IDs, please deploy your application to a device. Otherwise please change your ApplicationId to "test_client" and AdUnitId to one of the supported ad types as outlined in the documentation.
A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.ni.dll
Additional information: Could not load file or assembly 'Microsoft.Phone.Controls.Toolkit.resources, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
if you are using windows phone toolkit then
you have to include
xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
xmlns:cc="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
in your *.xaml page
I'm using Microsoft.Windows.Controls.Ribbon.
I want to have a dynamic combobox with picture buttons in my ribbon.
If I do this directly in xaml, I get what I want:
<ribbon:RibbonComboBox
SelectionBoxWidth="62"
VerticalAlignment="Center"
>
<ribbon:RibbonGallery SelectedValue="0"
SelectedValuePath="Content"
MaxColumnCount="1">
<ribbon:RibbonGalleryCategory>
<ribbon:RibbonButton Label="Histo" HorizontalContentAlignment="Stretch"
Command="{Binding NewHistogrammCommand}"
SmallImageSource="/Test;component/Resourcen/Histogramm32.png"
LargeImageSource="/Test;component/Resourcen/Histogramm32.png" />
<ribbon:RibbonButton Label="3D" HorizontalContentAlignment="Stretch"
Command="{Binding NewDreiDCommand}"
SmallImageSource="/Test;component/Resourcen/DreiD32.png"
LargeImageSource="/Test;component/Resourcen/DreiD32.png" />
</ribbon:RibbonGalleryCategory>
</ribbon:RibbonGallery>
</ribbon:RibbonComboBox>
But if I try to do this via binding to a collection this way:
<ribbon:RibbonComboBox
SelectionBoxWidth="62"
VerticalAlignment="Center"
IsEditable="True" >
<ribbon:RibbonGallery
MaxColumnCount="1">
<ribbon:RibbonGalleryCategory ItemsSource="{Binding LayoutContentTypeList, ElementName=mainWindow}">
<ribbon:RibbonGalleryCategory.ItemTemplate>
<DataTemplate>
<ribbon:RibbonButton Label="{Binding Header}" HorizontalContentAlignment="Stretch"
Command="{Binding Command}"
CommandParameter="{Binding CommandParameter}"
SmallImageSource="{Binding ImageSource}"
LargeImageSource="{Binding ImageSource}" />
</DataTemplate>
</ribbon:RibbonGalleryCategory.ItemTemplate>
</ribbon:RibbonGalleryCategory>
</ribbon:RibbonGallery>
</ribbon:RibbonComboBox>
I get
System.Windows.Data Error: 40 : BindingExpression path error: 'IsDropDownOpen' property not found on 'object' ''ContentPresenter' (Name='')'. BindingExpression:Path=IsDropDownOpen; DataItem='ContentPresenter' (Name=''); target element is 'RibbonButton' (Name=''); target property is 'NoTarget' (type 'Object')
The buttons work correctly, but how can I resolve this binding error?
I'm guessing that you've found a solution for your problem, but for other people coming across this post, looking for an answer, you can find a complete solution that you can download and examine at your leisure in the How do I add Galleries to my Ribbon? post at 'The official blog of the Windows Presentation Foundation Team'. The basic idea is as follows.
Whatever object that you set as the RibbonGallery.DataContext should have a collection property to bind to the RibbonGalleryCategory.ItemsSource property. The objects in that collection should have properties containing the values that you want to appear in the gallery items. Declare a HierarchicalDataTemplate for the RibbonGallery.CategoryTemplate to bind your properties. Here is an example from the linked post:
<Ribbon:RibbonGallery DataContext="{x:Static data:WordModel.StylesParagraphGalleryData}"
ItemsSource="{Binding CategoryDataCollection}"
ScrollViewer.VerticalScrollBarVisibility="Hidden">
<Ribbon:RibbonGallery.CategoryTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding GalleryItemDataCollection}">
<Border Background="LightGray">
<TextBlock Text="{Binding}" FontWeight="Bold" />
</Border>
<HierarchicalDataTemplate.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Image Source="Images\Paragraph_32x32.png" />
<TextBlock Margin="10,0,0,0" Text="{Binding}" />
</StackPanel>
</DataTemplate>
</HierarchicalDataTemplate.ItemTemplate>
</HierarchicalDataTemplate>
</Ribbon:RibbonGallery.CategoryTemplate>
</Ribbon:RibbonGallery>
I want to add a trigger to a dynamically created control but I couldn't. The event doesn't fire. This is my code.
<sdk:HierarchicalDataTemplate x:Key="NameTemplate"
ItemsSource="{Binding LstRs}"
ItemTemplate="{StaticResource RsTemplate}">
<TextBlock Text="{Binding Nom}" FontWeight="Bold" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseEnter">
<gs:EventToCommand Command="{Binding Path=StateCommand}"
CommandParameter="{Binding Text, ElementName=TextBoxSearch, Mode=OneWay}"
MustToggleIsEnabledValue="True"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</TextBlock>
</sdk:HierarchicalDataTemplate>
and the command is implemented in the view model.
IMHO, the most common error in such a case is that the command was not created - i.e. StateCommand == null - when the data is bound. Make sure you created the command in the constructor of you view-model.