Using a resw file in a Universal App - windows-store-apps

I'm following the instructions at http://msdn.microsoft.com/en-gb/library/windows/apps/xaml/hh965326.aspx on how to add a resources file, but I must be doing something wrong because it doesn't work.
I created a new Universal app, checking that the Default language is set to en-US in both Package.appxmanifest files.
I created a Resources.resw file, in Strings/en-US. This file has three values:
Greeting.Text = Hello
Greeting.Width = 20
Farewell = Goodbye
Then, in MainPage.xaml, I've got the following:
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<StackPanel Orientation="Vertical">
<TextBlock x:Uid="Greeting" Text="" />
</StackPanel>
</Grid>
When I run the app, nothing appears - the text box has no content. The instructions in the MS quickstart don't say it, but does some sort of additional association have to be done, such as referencing the Resources.resw file in the App.xaml?

I assume you meant TextBlock (not TextBox) has no content when you run the app.
A couple of things to check:
Does it help if you delete Greeting.Width or set it to a larger value (maybe TextBlock) is to narrow to show anything)?
Could the text be hidden behind the performance counters in the top left corner of the app? Try adding Margin="100" to your TextBlock just to be sure.
Do you have BuildAction for Resources.resw set to PRIResource?
You don't have any other code which could affect the content of your TextBlock?
If this doesn't help, can you put your sample somewhere for download? This would make it easier to troubleshoot.

Related

Display Text with HTML image tag inside WPF control

I try to display a Text that contains a string plus HTML tags, and render images.
SourceText="TextToDisplay <img Source="Http://...cat.png"> and thats <b>it</b>";
RichTextBox doesnt work well.
I found some NuGet packages:
HtmlRenderer : But cannot access image that needs my Windows credentials to access, no way to send credential, so i got error 404 for images.
HtmlAgilityPack : Does not work for images
HtmlRichTextBoxBehavior : Does not work for images
I'm out of ressources....
Use case is I try to replicate TFS Description box in a WorkItem, it can contains HTML tags.
When i query TFS api to get Description, thats what we receives and i want to display the same box with the same iamges....
It's WPF, so you can just build whatever custom control you want very easily.
Start with a TextBlock and an Image control inside a StackPanel and go from there. It doesn't have to be any more complicated than that if you don't want it to. Or you can add a bunch of extra functionality if you need extra features. WPF gives you the flexibility to build whatever you want.
<StackPanel>
<TextBlock Text="TextToDisplay"/>
<Image Source="http://myUrl.../myImage.png"/>
</StackPanel>
This places them one after the other. If you want them to overlay one another, use a Grid to hold them. If you want a MouseOver effect, use a PopUp control. If you want an actual hyperlink in the UI, use the WPF Hyperlink element.

UWP ListView in touch mode

I have this ListView in a Windows 10 project:
<ListView ItemsSource="{x:Bind ViewModel.ItemsList, Mode=TwoWay, Converter={StaticResource BindableSourceConverter}}"
ScrollViewer.HorizontalScrollMode="Disabled"
ScrollViewer.VerticalScrollMode="Disabled"
RelativePanel.Below="pageHeader"
CanReorderItems="True"
SelectionMode="None"
CanDragItems="True"
AllowDrop="True"
CanDrag="True" />
and i need to allow the user to reorder the ListView.
Using mouse everything works fine, but using the touch, i need to wait one second before that i'm able to move the items around.
Any idea on how to fix that?
There isn't any, if you don't wait one second internal ScrollViewer thinks you do scroll action. Since it can't know your intention for sure, it can't know the difference.
If you don't need scroll action, consider not using ListView.

Why does attempting to use the "Protected" Windows Store App Bar icon crash my app?

With this XAML:
<AppBarButton Icon="Protected" Label="Privacy Policy" >
<AppBarButton.Flyout>
<Flyout>
<StackPanel>
<TextBlock MaxWidth="200" Text="Photrax extracts information from images you load into it. The information it extracts includes location information (where the photos were taken, when that is available) and the date and time the photo was taken. This data is stored in a local/internal/embedded (SQLite) database. This data is not stored in the cloud but only on your local device." TextWrapping="Wrap" FontSize="13" FontFamily="Verdana">
</TextBlock>
<TextBlock MaxWidth="200" Text="To reiterate: Your data is not shared with anyone else. It is stored only on the device from which you use Photrax." TextWrapping="Wrap" FontSize="13" FontFamily="Verdana">
</TextBlock>
</StackPanel>
</Flyout>
</AppBarButton.Flyout>
</AppBarButton>
...my app crashes with, "An exception of type 'Windows.UI.Xaml.Markup.XamlParseException' occurred...Failed to create a 'Windows.UI.Xaml.Controls.IconElement from the text 'Protected'"
Yet "Protected" is one of the official listed icons as shown here.
If I change this:
<AppBarButton Icon="Protected"
...to this:
<AppBarButton Icon="Help"
...it works fine (but doesn't sport the preferred icon), so it's my attempt to use the "Protected" icon that's causing my headaches. Why? How to remedy?
The list you linked is for Windows 8. For Windows 8.1 see http://msdn.microsoft.com/en-us/library/windows/apps/xaml/windows.ui.xaml.controls.symbol.aspx
You're probably looking for ProtectedDocument rather than Protected.

Strange behavior horizontal scrollview of app when create with VS 2012

I'm learning Windows Store App development, I create a simple project with "Grid App" in Visual 2012, after that I run app and see that the Horizontal Scrollbar behavior very strange, see the screenshot:
Anyone see this problem? I try to create the Grid App in VS 2013 and it's work correct, I think it's a bug of VS 2012 right?
Thank you!
This is not bug in Vs 2012..this is occur because of virtualization i.e
listbox or listview not loaded all content when it is loaded first time but when u start to scroll it start to load content ..so as no of content loaded thumb start to become small in size..thats why initially thumb appear as big and later small when scroll.for example you can visit facebook(vertical scrollviewer).
refer this link for understanding http://msdn.microsoft.com/library/windows/apps/windows.ui.xaml.controls.listview.aspx
In winrt default gridview style ItemsPanel like this ..visit style of gridview (C:\Program Files (x86)\Windows Kits\8.0\Include\WinRT\Xaml\Design)
<Setter Property="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
<WrapGrid Orientation="Vertical" />
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
and ItemsPanelTemplate wrapgrid is inheriated from VirtualizingPanel http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.wrapgrid
VirtualizingPanel is used for virtualiztion purpose and as you said it is not in vs 2013 means they haven't used VirtualizingPanel for itemspanel..
Visit this links
http://msdn.microsoft.com/en-us/library/windows/apps/hh780657.aspx
http://msdn.microsoft.com/en-us/library/windows/apps/hh994637.aspx
thank you

Disable the swap in WP8

I'm developing windows phone 8 application.
How I can disable the swap between the items in the pivot page ? since I disabled the IsHitTestVisible property to do that.
But When I used it ; controls in the item page doesn't accept input from user?
How I can disable the swap ? and allow the input from the user in the same time ?
In order to stop the Pivot on WP8 for switching PivotItems, use the new Pivot.IsLocked=true property. Read more about it here # http://msdn.microsoft.com/en-us/library/windowsphone/develop/microsoft.phone.controls.pivot.islocked(v=vs.105).aspx
For example, this code snippet shows how to use Pivot.IsLocked on WP8:
<phone:Pivot IsLocked="True">
<phone:PivotItem Header="Foo">
<TextBox />
</phone:PivotItem>
<phone:PivotItem Content="Bar" Header="Bar" />
<phone:PivotItem Content="Baz" Header="Baz" />
</phone:Pivot>
When you run this code snippet you can see the Pivot only shows the first PivotItem but you can still interact with it (which isn't possible if you simply set IsEnabled=False).
For WP7, use there's a LockablePivot in the Windows Phone toolkit that support this same property. Read more about it here # http://www.windowsphonegeek.com/articles/Windows-Phone-Toolkit-LockablePivot-in-depth