Windows phone 8 viewport control - xaml

I try to understand how windows phone viewport control Bounds work.
So i can give
viewport.Bunds = new Rect(x,y,width, height);
but what that bound stand for is it a scrollable area in the viewport.
Can anyone give me a working simple example of it cause whenever i try to use this parameter i can't scroll in viewport whatsover
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="0,0,0,0">
<ViewportControl Name="tuzik" Bounds="0,0,300,400" Margin="66,117,20,41" >
<Canvas Name="canvas">
<Image Name="TestImage" Source="Assets\testimage.jpg"
HorizontalAlignment="Left" VerticalAlignment="Top"
Canvas.Left="-379" Canvas.Top="-769" Stretch="Fill" />
</Canvas>
</ViewportControl>
<Rectangle x:Name="rect" Width="300" Height="400" Margin="60,111,63,0" Stroke="Aqua" />
</Grid>

I believe your problem is the Canvas within the ViewportControl. Canvas does not expand to fill the ViewportControl and will not expand to contain the contents, either. You have to set a Width and Height on the Canvas.
(At least, that's how I have mine setup.)

Related

How to resize NavigationView and SplitView in UWP

I want to enable user to resize the NavigationView in my UWP app. Couldn't find any resources how I could do that.
I see some of the apps have "Resizable splitView" but for SplitView also, I cannot see any such resize property exposed to set by default.
Pls help.
Thanks in Advance
There are no such property can resize SplitView and NavigationView, you need to custom layout to implement a similar effect. You could use Slider control and bind the OpenPaneLength Property of SplitView to Slider.Value to do this. Please refer to the following code.
<Grid>
<SplitView Name="CoreSplitView"
DisplayMode="Inline"
IsPaneOpen="True"
OpenPaneLength="{Binding Value, ElementName=MasterSlider, Mode=OneWay}">
<SplitView.Pane>
<Grid Name="PaneGrid" Background="Gray">
<Slider Name="MasterSlider"
MinWidth="480"
VerticalAlignment="Stretch"
Maximum="480"
Minimum="10"
Opacity="0"
Value="150"
/>
<StackPanel Name="PaneStackPanel"
Margin="0,0,10,0" Background="LightGray">
<TextBlock TextWrapping="Wrap" Text="Use a slider when you want your users to be able to set defined, contiguous values (such as volume or brightness) or a range of discrete values (such as screen resolution settings).A slider is a good choice when you know that users think of the value as a relative quantity" />
</StackPanel>
</Grid>
</SplitView.Pane>
<Grid Name="ContentGrid" Background="LightSteelBlue">
</Grid>
</SplitView>
</Grid>
The StackPanel that is directly under our slider, acts like a cover for our Slider. Notice the StackPanel has Margin="0,0,10,0", this translates to a 10px distance from the right wall, which allows the Slider area to be exposed as a gray strip that is used to drag the Pane, again the 10px is arbitrary but it has to match the Minimum of the Slider.

How to bind InkCanvas height and width to an image

I have an Image control in a Grid that is displayed when the user clicks on an image in a list. I want to add an InkCanvas control directly on top of the Image control so the user can draw on it.
However, it seems like the height and width of the InkCanvas is not being bound correctly to the image and I am able to draw outside the image. What else do I need to do?
My XAML code:
<Grid>
<Image x:Name="result_img" VerticalAlignment="Center" HorizontalAlignment="Center"/>
<InkCanvas x:Name="inkCanvas" x:Load="False" Height="{x:Bind result_img.ActualHeight}" Width="{x:Bind result_img.ActualWidth}"/>
</Grid>
Code-behind (C++/CX):
void MyGui::test::ListView_ItemClick(Platform::Object^ sender, Windows::UI::Xaml::Controls::ItemClickEventArgs^ e)
{
this->FindName("inkCanvas");
inkCanvas->InkPresenter->InputDeviceTypes = CoreInputDeviceTypes::Mouse;
}
Any help would be much appreciated!
If you want to use element-to-element binding,you should use the ElementName property.The ElementName is the name of the control you want to bind and the Path is the property of the control you want to bind.
<Image x:Name="result_img" VerticalAlignment="Center" HorizontalAlignment="Center" Width="300" Height="400" />
<InkCanvas x:Name="inkCanvas" x:Load="False" Height="{Binding ElementName=result_img, Path=ActualHeight}" Width="{Binding ElementName=result_img, Path=ActualWidth}"/>

Inmobi ads Displayed issue on Windows Phone 8

I want to set the Inmobi ads on the bottom of the screen.
In XAML i set the Horizontal and Vertical alignment in bottom. when i saw the design i saw the AdView in bottom of screen but when i deploy it By default it appear in Middle.
I'm confused am i did mistake anywhere either it always appear on that place.
<StackPanel x:Name="ControlPanel" VerticalAlignment="Bottom" HorizontalAlignment="Center" Margin="0,0,0,55" Grid.Row="3" Width="480" >
<Ad:IMAdView
x:Name="AdView1"
RefreshInterval="30"
AdSize="15"
AppId="fcc4c048-4686-42bc-a40c-b7fe8da70b40"
Height="110" Width="480"
AnimationType="SLIDE_IN_LEFT" HorizontalAlignment="Right" VerticalAlignment="Bottom"
Margin="0,0,0,30" >
<Ad:IMAdView.IMAdRequest>
<Ad:IMAdRequest
LocationInquiryAllowed="False"/>
</Ad:IMAdView.IMAdRequest>
</Ad:IMAdView>
</StackPanel>
Changing your stackpanel's HorizontalAlignment property from "Center" to "Right" will work for you...

How to design a Conversation view in windows 8 Metro App?

I'm Trying to design the Conversation View for a chat Application in windows 8 Metro App. I'm new to xaml designs, how to set the Conversation view like the image below,
Although at first time it seems this layout can be fit into Grid with three columns, I'm sure you would need scrolling at some point. So, you can just use Canvas, which allows free-floating controls. Place them with Canvas.Left and Canvas.Top attached properties.
Update: an illustration of what I mean:
<Canvas Width="300" Height="200">
<Border Width="40" Height="40" Canvas.Left="10" Canvas.Top="60" Background="Red"/>
<Border Width="160" Height="80" Canvas.Left="60" Canvas.Top="60" Background="LightGray"/>
<Border Width="40" Height="40" Canvas.Left="250" Canvas.Top="150" Background="Red"/>
<Border Width="160" Height="30" Canvas.Left="80" Canvas.Top="150" Background="LightGray"/>
</Canvas>
Let's pretend that red borders are user pics (put Image inside) and gray borders are messages (put RichTextBlock inside.) Canvas allows you to shift those blocks freely.

silverlight 4.0 scrollviewer not updating

I am new to Silverlight. I am trying to provide a zoom in functionality along with inkpresenter. I am using Silverlight 4, c#, asp.net. I can bind the slider to canvas and it does zoom in but i am facing problem with the scrollviewer layout which is not updating. there are allot of post that mentioned that i need to used layout transform. Can any one please let me know what i am doing wrong or any other suggestion.
<Slider x:Name="slider" Maximum="2" Minimum="0" Value="1" Width="100"/>
</StackPanel>
<ScrollViewer x:Name="scrollBar" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto" Grid.Column="1" Margin="6,1,1,1" Grid.Row="1">
<ScrollViewer.Content>
<toolkit:LayoutTransformer Name="TheTransformer" Background="{x:Null}">
<toolkit:LayoutTransformer.LayoutTransform>
<ScaleTransform x:Name="contentScale" ScaleX="{Binding ElementName=slider,Path=Value}" ScaleY="{Binding ElementName=slider,Path=Value}" />
</toolkit:LayoutTransformer.LayoutTransform>
<toolkit:LayoutTransformer.Content>
<Canvas x:Name="cnsImageEditable" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" OpacityMask="#FFE89E9E">
<!--The following commented bit does work i can zoomin and out but scroller not updating -->
<!--<Canvas.RenderTransform>
<ScaleTransform x:Name="scale" ScaleX="{Binding ElementName=slider,Path=Value}" ScaleY="{Binding ElementName=slider,Path=Value}"/>
</Canvas.RenderTransform>-->
<InkPresenter x:Name="inkCanvas" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Image x:Name="imgEditableImage" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"></Image>
</InkPresenter>
</Canvas>
</toolkit:LayoutTransformer.Content>
</toolkit:LayoutTransformer>
</ScrollViewer.Content>
</ScrollViewer>
any help is much appretiated thanks
Check out https://stackoverflow.com/questions/9899729/layouttransformer-in-silverlight-not-working , worked for me. Specifically:
I found that Transforms in silverlight happens after Layout, so I changed the CanvasWidth property only once till the scrollbars show, and then zooming would work perfectly,