I would like to have a MarkupExtension that can be initiated with just one value, much like Binding:
<TextBox Text="{Binding MyPath}"/> instead of <TextBox Text="{Binding Path=MyPath}">
In WPF this is done with the ConstructorArgumentAttribute, but this doesn't exist in Silverlight.
I checked for attributes on the Path property of Binding but have'nt found any attributes applied to it.
Any ideas?
For now I realize that it's not yet implemented.
So if you think this feature is compelling, please go ahead and vote for this feature here.
Hope this answer to be updated as soon as I have any piece of news (hope this to happen asap...).
Related
In my last years release i used net core 3 and WPF like that:
<Label Content="{x:Static p:Resources.WJAJobtitle}" VerticalAlignment="Center"/>
Now i'm trying to upgrade to net 5 with WinUI3. As far as i read, i have to use now TextBlock instead of Label. I read the docs, but haven't found anything about static resources.
Maybe anyone knows, how to set it correctly?
As found there the new format for such things are:
<TextBlock x:Uid="WJAJobtitle"/>
Hello I have this following code
<controls:FlowListView x:Name="Board"
HasUnevenRows="true"
BackgroundColor="Black"
FlowColumnCount="3"
FlowItemTappedCommand="ExecuteAction">
<controls:FlowListView.FlowColumnTemplate>
<DataTemplate>
<StackLayout>
<Image VerticalOptions="FillAndExpand" Source="GetImageGivenCard"></Image>
</StackLayout>
</DataTemplate>
</controls:FlowListView.FlowColumnTemplate>
</controls:FlowListView>
This FlowListView ItemsSource will be a list of Cards. GetImageGivenCard would be a method which would acess a cache and retrieve an image given a designated card, all this asynchronously ofcourse (I'm using Akavache). Is what I'm trying to achieve possible ? If not, can you please give me some alternative solutions ?
Thank you for your time guys.
edit:
Source="GetImageGivenCard"
This line doesn't work ofcourse, it's only pseudocode for showing you what I would be hoping to obtain
Use https://github.com/luberda-molinet/FFImageLoading
It is a good plugin (caching, async, imageloader, placeholder included)
I hope somebody can help.
I've spent some time researching the best way to bind an event to a ViewModel command using the MVVM pattern when developing a Universal App. I'm using MVVM Light.
As a test I'm using the SelectionChanged event of a ComboBox.
I've read a few people that have pinched the Behaviours SDK from the Windows 8.1 / WinRT framework and had some success with that. I have also included the Universal App behaviours SDK in my project and tried the following (put together from Windows 8.1 examples but using the UWP SDK).
XAML
<Page
xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
xmlns:core="using:Microsoft.Xaml.Interactions.Core" />
...
<ComboBox ItemsSource="{Binding InputQuantities}">
<interactivity:Interaction.Behaviors>
<core:EventTriggerBehavior EventName="SelectionChanged">
<core:InvokeCommandAction Command="{Binding SomeComboBoxCommand}" CommandParameter="Foo" />
</core:EventTriggerBehavior>
</interactivity:Interaction.Behaviors>
</ComboBox>
View Model
public RelayCommand SomeComboBoxCommand {get; set;}
However, the core:InvokeCommandAction isnt part of the Behaviours SDK and i get Invalid Type: expected type is 'Microsoft.Xaml.Interactivity.ActionCollection'. I've tried to use an ActionCollection.... but I'm not sure I know what I'm doing with that.
Ive successfully got it to work with compiled bindings and using Laurent's Blog Post:
XAML
<ComboBox ItemsSource="{Binding InputQuantities}" SelectionChanged="{x:Bind Vm.SomeComboBoxCommand }" />
View Model
public void SomeComboBoxCommand(object sender, SelectionChangedEventArgs e){//do stuff}
I know this isnt what Laurent is intending to demonstrate here and I think doing this is breaking the decoupling of the view and VM by then having to reference a UI component in my view model to get the selected item. But I've seen references to doing this during my research.
So how can I get this working using The Universal App interaction behaviours, if that's the right way to do it of course?
Update 1.
This is what I attempted to add, believing, incorrectly that I was adding the universal app behaviours SDK. I didn't notice at the time that it was targeting Windows 8.1.
However, my questions still stands: Why wont the InvokeActioncommandwork and why is it throwing the mentioned error? I will look at the other posts as soon as I get to work.
Update 2
After testing this on my works PC (exact same code as above, 1st example and the same behaviours SDK) it works fine and I'm getting the behaviour that I would expect. I need to test again on my home PC to see what has gone wrong. (Thanks to Justin XL for sticking with me)
Update 3
For completeness, after returning home I got the latest version of my project (from being checked in on my works PC) and it now also works on my home PC. I'm not sure what state my Visual Studio was in but it had sufficiently confused me enough to post this question. At least this should serve as a document on how to do what is described in the title. Thanks for all your help.
We seem to be getting this question a lot lately, in several different variants...
I'm not familiar with Universal App but is there any specific reason you're trying to use an event? WPF/Silverlight etc are designed to be data driven, all you need to do is bind the ComboBox's SelectedItem member to a property in your view model and the setter will get called whenever the user selects a new item. Often times you have to do exactly the same processing in response to other parts of your view model changing it (e.g. in Master-Child views) so having that logic in a single place generally makes for a much cleaner architecture.
Check this link: MVVM EventBinding Library ,explains about MVVM EventBinding. This purely decouples the View & View model & pass only the arguements to the command.
I have portable library in which I have AppLocalizations.resw resource files. I can read it in the code behind (which is obsolete, but working):
new Windows.ApplicationModel.Resources.ResourceLoader("Assembly/AppLocalizations")
But how can I use it from the xaml? When I try to read it this way, the text is blank, even if the key in the resource file is Key.Text
<TextBlock x:Uid="Key" />
I was triying to import it in the App.xaml, but with no success.
Thanks.
I use this code with Windows Phone Universal Apps, but with a general resources:
<TextBlock Style="{StaticResource TextBlock_BlackStyle}" x:Uid="/Resources/txtIPName" Name="txtIPName" HorizontalAlignment="Left" Margin="33,149,0,0" TextWrapping="Wrap" Text="IP:" VerticalAlignment="Top"/>
Then if u had exertanl library, I think the code is:
<TextBlock x:Uid="/Assembly/AppLocalizations/Key" />
Tell me if I solve your problem! Good luck man! :)
I've Been working with WP7 for a while, am using listPicker/DatePicker Heavily. i hate its design though.i use liskPicker's property ExpansionMode="FullScreenOnly". i tried to make those controls to look prettier by
// Setting A source to the FullModeItemTemplate
FullModeItemTemplate="{StaticResource lpkFullItemTemplate}"
//the definition for this Resource is as follows:
<DataTemplate x:Name="lpkFullItemTemplate">
<StackPanel Orientation="Horizontal" Margin="5 5 5 5" Background="#FFA3A3A3"
Width="475" Height="45" >
<TextBlock Text="{Binding}" Foreground="Black" Margin="5 5 15 5" />
</StackPanel>
</DataTemplate>
I need real changes, changing the background of that popup and such changes, is that possible? or i need to build my own popup from scratch?
In order to do that you will have to create a copy of the ListPickerPage.xaml file from the Silverlight for Windows Phone Toolkit in your application, change it to meet your requirements, and then on your ListPicker control set the PickerPageUri proprety to the new ListPickerPage.xaml
I would like to improve Pedro's answer, but I still can't comment. You can see there's some people making questions up there.
In order to copy the ListPickerPage you'll need both the ListPickerPage.xaml and ListPickerPage.xaml.cs files. If you want those files to compile, you need some extension methods defined on Extensions.cs, ItemsControlExtensions.cs and VisualTreeExtensions.cs. You can either copy those three files or cherry pick the methods you need and add them to your own file.