Wanted to set background image of TableCell in
<TableCell ColumnSpan="1" Background="{$Sign}">
<Paragraph >
<Figure HorizontalOffset="0" VerticalOffset="0" >
<BlockUIContainer>
<Image Source="{$tickmark}"></Image>
</BlockUIContainer>
</Figure>
</Paragraph>
</TableCell>
When I try to parse it an exception occurs
XAMParserException:- failure to create background from text "C:\Users\Home\abcd.png"
{$Sign} is a variable defined at top of xslt which contains the path.
I've also tried writing the complete path rather than writing {$Sign}.
Kindly help. Please explain how to set background image of a cell in flowdocument.
Related
I would like to create backdrop for pop up window.
By backdrop I mean semi transparent background which is behind popup and stretches on a whole application screen. This makes the popout window more dominant and blocks the possibility to click on anything else in the background.
It would be best if popup window xaml code is deep inside the structure of the view if possible. Not at the top of hierarchy or bottom.
My issue with this is that the backdrop size wont stretch over its parents size.
So if my view is
1000x1000
My content in view is
500x500
and my pop up window is in this 500x500 it wont stretch over this size.
I tried with Position absolute, relative, translatin x/y, adjusting margins to high values to get bigger size.
I just cant get it done.
Example
You can use the Plugin PopupPage .And set the layout of popup as you want
<?xml version="1.0" encoding="utf-8" ?>
<pages:PopupPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:pages="clr-namespace:Rg.Plugins.Popup.Pages;assembly=Rg.Plugins.Popup"
xmlns:animations="clr-namespace:Rg.Plugins.Popup.Animations;assembly=Rg.Plugins.Popup"
x:Class="MyProject.MyPopupPage">
<!--You can set an animation in the xaml file or in the csharp code behind-->
<pages:PopupPage.Animation>
<animations:ScaleAnimation
PositionIn="Center"
PositionOut="Center"
ScaleIn="1.2"
ScaleOut="0.8"
DurationIn="400"
DurationOut="300"
EasingIn="SinOut"
EasingOut="SinIn"
HasBackgroundAnimation="True"/>
</pages:PopupPage.Animation>
<!--You can use any elements here which are extended from Xamarin.Forms.View-->
<StackLayout
VerticalOptions="Center"
HorizontalOptions="Center"
Padding="20, 20, 20, 20">
//...
</StackLayout>
</pages:PopupPage>
And for more details you can check https://github.com/rotorgames/Rg.Plugins.Popup/wiki/Getting-started
I've loaded a series of svg images by creating and storing a CanvasSvgDocument for each, and using its LoadAsync() method to load the svg:
nextSvg = CanvasSvgDocument(resourceCreator.Device());
auto fileStream = co_await nextFile.OpenReadAsync();
co_await nextSvg.LoadAsync(resourceCreator.Device(),fileStream);
This appears to load the svg, but when I use that stored svg in a drawing session nothing appears in the CanvasControl. Other items draw fine: shapes, lines, etc. - just not svgs:
session.DrawSvg(m_svg, boxSize, top, left);
In an attempt to discover the problem I've tried using GetXml() on the svg document in the hope that would show me its contents. The result is an abbreviated svg with no drawing information. I provide that here in case it's a hint:
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"></svg>
Perhaps that is all that GetXml() is supposed to return?
I have successfully drawn svgs if they loaded as imagesources; the resulting bitmap image works. But is it possible that session.DrawSvg() is just not completely implemented yet in Win2D? I'd rather render the svg directly this way if it can be done.
[Update] p.s. The svgs are version 1.1 svgs converted from pdfs by one of the online conversion services. As I mentioned, they render fine if opened in Edge or other browsers.
[Update2] Thinking perhaps there is something in the svgs that Win2D doesn't like, I tried creating a simple one using as a model an online example - it just has a rectangle and a circle, as follows. But it also does not draw:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 140"
preserveAspectRatio="xMidYMid meet">
<title>Scalable Vector Graphics (SVG) Demo</title>
<circle cx="100" cy="100" r="50" stroke="#000" stroke-width="1" fill="#ccc" />
<rect x="200" y="50" width="250" height="100" rx="5" ry="5"
stroke="#000" stroke-width="1" fill="#ccc" />
</svg>
[Update] It appears that the problem lies in the way the svg is read from the Storage File. I'll post my own answer as soon as I have enough that it might be useful to someone.
The answer is that my code contains an egregious error: As was pointed out to me at GitHub, LoadAsync() is a static method. In my first line above, I create a CanvasSvgDocument, but in the third line I ignore the results of LoadAsync. LoadASync is also a constructor, so the proper code is
auto fileStream = co_await nextFile.OpenReadAsync();
nextSvg = co_await CanvasSvgDocument::LoadAsync(resourceCreator.Device(),fileStream);
That works! Only trouble is that what I really want is to use LoadFromXaml(), another static method, and there is a different issue with that to be addressed later. Probably also my error.
I'm new to Xamarin.
When I try to insert a Button or a BoxView I can set the "HeightRequest" and "WidthRequest" Parameters but the elements are just filling the whole screen.
What am I doing wrong?
You have done nothing wrong, but you missed some key procedure. you did not set LayoutOptions of Button or BoxView. The following code could make element size effected.
<Button Text="click me"
HeightRequest="44"
WidthRequest="60"
VerticalOptions="Start"
HorizontalOptions="Start"/>
As you know, the button control is inherited from the View. The default value of VerticalOptions dependency property is LayoutOptions.Fill. And it also works for HorizontalOptions. So if you did not set value for VerticalOptions and HorizontalOptions, the control will fill the whole screen.
I have XAML code to create program output in frame. I can change content of frame in case I used "MyFrame.Navigate(typeof(Setup))". Is there any way to initialize content of frame in XAML code?
XAML code fragment:
</SplitView.Pane>
<SplitView.Content>
<Frame Name="MyFrame" ?any reference to view to first time intiilaization? />
</SplitView.Content>
Thanks for help
You can use SourcePageType
It can set in xaml ,the code is
<Frame Name="MyFrame" SourcePageType="Setup"></Frame>
The frame will navigate to Setup
I think you can use the control above in the Frame when you enter the page ,you can set it Visibility and you can set is hidden when load complete.
I want to change part of a label dynamically.
This is my code:
<View top="0" height="115">
<Label id="lblMiles" left="15" textAlign="right" right="15" top="0" height="55">
{distance} Miles
</Label>
</View>
I want to be able to change the {distance} portion dynamically.
However currently I can only change the whole thing like this:
$.lblMiles.text = "10 Miles";
In HTML we normally use a span tag like so:
<div id="lblMiles"><span id="distance"></span> Miles</div>
How can I do something similar in Alloy?
If it were up to me, i wouldn't worry about updating only half the label, just reset the whole text,
$.lblMiles.text = "10 Miles";
// and then later on to update it to 15
$.lblMiles.text = "15 Miles";
if for some reason you need to update only half, then you could use two labels and put them in a view with layout set to horizontal.
something looking like this :
<View top="0" height="115">
<View height="Ti.UI.SIZE" width="Ti.UI.SIZE" layout="horizontal">
<Label id="dynamicLabel" />
<Label id="lblMiles" > Miles</Label>
</View>
</View>
and then in your code, just update the dynamic label setting the actual value:
$.dynamicLabel.text = "15";
Now to position the labels on the screen you should play on the attributes of their container's left, right, top and bottom.
You can do this by two three ways
Have two different labels and set it from controller
You can use attributed strings as well.
More reference is here http://docs.appcelerator.com/platform/latest/#!/guide/Attributed_Strings