i'm fairly new at this so i apologize in advance if i say anything stupid.
I am making a UI in WPF that consists of 8 buttons to open various programs set on my computer. Currently i am trying to get the buttons in the UI to scale based on the detected window size.
The problem i am having is trying to get the calculations done in the C# code to link over to the scale transform option for the buttons in XAML.
I have searched high and low to find a solution but i still cannot find a way to link the value to XAML. Does anyone know of a guide for something like this and should it be done using a converter?
Thanks for any help.
When you need your content to autoscale, put it all into a ViewBox control.
<Window>
<Viewbox>
<Grid x:Name = rootGrid>
</Grid>
</Viewbox>
</Window>
Now everything will magically fill to the window size and scale! Instant awesomeness for your app.
Related
Basically, I have a lot of xaml code that uses margins, and is base on the 1366x768 screen size. Unfortunately, my monitor is 1920x1080, so when it launches, my UI seems a little bit squished and the data is pushed to the wrong place. Is there a way to make my program launch in 1366x768 and not be allowed to change screen size?
Also maybe, if I do go 1080p, it still looks good - like, some of my ui elements just move across the page, and all my combo boxes just get huge
Does this all make sense? If not, just say :)
To answer your first question, all you need to do is set the "ResizeMode" property of the Window:
<Window x:Class="TestWPF.MainWindow"
....
Title="MainWindow"
ResizeMode="NoResize"
Height="1366" Width="768">
Regarding the second part of your question. I have a feeling that perhaps you're not quite using the available ways to lay out controls in WPF properly. UI Elements shouldn't move across the screen if you use Grids, DockPanels, and StackPanels to lay out your controls. I'd recommend you look at some examples. Post your XAML if you want a more specific suggestion regarding this :).
I've been working on an application in Visual Studio and I've stumbled on a problem for an annotation feature I wish to implement. Basically, I would like to be able to use my mouse to draw on the screen. I checked some other questions here initially and thought to make a transparent window to draw on, but making the window fully transparent caused my mouse clicks to trigger other windows, which won't work.
I then tried to set an extremely low opacity for the window with a white background, which caused the screen to be slightly shaded, which was fine. However, doing this for the whole window caused the line I drew to also have an extremely low opacity and thus remain basically invisible.
Is there a way to solve this problem using the transparent window, or will I have to do something like take a screenshot and make a window-sized picture for the user to draw on? This seems less elegant of a solution and for other features in my application, I would like to avoid this if possible, but if that appears to be the only way, some help in the implementation would be really appreciated.
Thank you!
Kevin
Don't set the Window's Opacity but instead use a Background with low opacity, e.g. #01FFFFFF:
<Window ... Background="#01FFFFFF">
...
</Window>
Alternatively you could explicitly create a SolidColorBrush as Background and set its Opacity to a small value:
<Window ...>
<Window.Background>
<SolidColorBrush Color="White" Opacity="0.01"/>
</Window.Background>
...
</Window>
I've searched loads for an answer to my problem.
Basically on my WP8 app, I have an "add record" page and a list of text boxes. I can scroll up and down the full length of the page fine, but when I tap one of the text boxes and the keyboard appears, I can no longer scroll to the very bottom and therefore can't complete the last couple text boxes.
Now, if you have a look at the MS calendar app on WP8, the "new appointment" page has a similar thing - when you tap one of the text boxes you can still scroll the whole way up and down.
I was wondering, is there anywhere I can see the XAML that MS have used? Then I can learn from that. I'm sure it's as simple as setting a height property or something but I've been stumped on this for a while now.
Rather than posting my XAML etc, does anyone know where I can get a look at the XAML for the MS stock apps? If this is even possible...
Thanks
I had the same issue. but at last i solved it, i just used the Height property to do this. i already answered for the same type of problem posted by someone.Please do the following steps
First create a ScrollViewer
Indide the ScrollViewer create a container(eg: Grid/StackPanel/Border etc...) and put every controlls inside it.
Set fixed Height for ScrollViewer and the Container (Note: Height of container should be greater than ScrollViewer's Height)
See the below Code
<ScrollViewer Height="500">
<Grid Name="Container" Height="700">
<TextBox/>
<TextBox/>
<TextBox/>
</Grid>
</ScrollViewer>
Now you can scroll the container Grid Even the KeyBoard shown or even focus on a TextBox.
I am developing Windows store apps. In one of the apps, instead of having image controls, I would like to have container controls that display single animated images from within (Similar to the News Bento app welcome screen on Windows 8). The closest I have come to that is AnimatingContainer control from WinRT XAML toolkit, but it doesn't seem to work with images (At least in my case). Any help on how to use this control to animate an image or any other solution will be grateful. Below is my XAML code. If I uncomment the text block and comment the image, the text block is displayed animated. But the reverse isn't true.
<Controls1:AnimatingContainer HorizontalAlignment="Left" Height="311" Margin="163,23,0,0" RadiusX="25"
RadiusY="10"
Duration="0:0:10"
VerticalAlignment="Top" Width="461">
<!--<TextBlock Text="Sume Rossini" FontSize="66"/>-->
<Image Source="Assets/Davy_Jones.jpg" Width="300" Height="500"/>
</Controls1:AnimatingContainer>
There likely isn't any. You would need to write one yourself to fit your specific requirements. Use Blend to create the animation. Ask more specific questions and you may get help implementing it.
I want to create an app that is somewhat of an iPhone emulator (and by emulator I mean user control that looks like a picture of an iPhone but it's still just all .NET under the hood).
I just want to use it to demonstrate/prototype some ideas and see how it would look on the phone and could demonstrate it's functionality to others. Why WPF? Because I'm a .NET developer and I don't want to spend much time on learning something I may never use.
Does anyone know if a control like this exists? Or a pre-made style?
Thanks!
If you just want an iphone picture and then the ability to put arbitrary controls inside of it, do something like this inside your XAML:
<Grid>
<Grid.Background>
<ImageBrush ImageSource="iphone.png" />
</Grid.Background>
<Frame Name="sourceFrame" Source="springboard.xaml" Margin="left,top,right,bottom" />
</Grid>
iPhone.png needs to be a picture of the iphone. You can find these readily available on the internet. Open the image in a picture editor and find the distance to the left side of the actual screen and put that in the margin for left. Do the same for top, right, and bottom. Then just create springboard.xaml, and you're set.