I'm designing a WPF application, and I wanted it to have a customized left menu. Actually I would like the left menu to look like on the image:
I know this has something to do with overriding the template, but I'm not sure how to draw that shape. Any suggestions please?
well i don't know if this is what you want but try this code:
<WrapPanel>
<Rectangle Width="50" HorizontalAlignment="Left" Height="200" Fill="Aqua"/>
<Border CornerRadius="0,100,100,0" Width="50" HorizontalAlignment="Left" Height="200" Background="Aqua"/>
</WrapPanel>
this can be done by Combining shapes in WPF. Take a look at this tutorial.
Related
I have an Image control in my view bound to BitmapSource prop in my View Model. This property is updated with images from a camera in my Model class. To get started with drawing shapes on images (so 1 control ON another),after
reading a similar post, I tried the following with a simple Rectangle
shape with Zindex=2 so it should act as an overlay over the image. But the
below doesn't work & all I see is the image from the camera
<Canvas>
<DockPanel Width="400" Height="250">
<Label DockPanel.Dock="Top" HorizontalAlignment="Center"
Content="IMAGE FROM CAMERA" Width="Auto"/>
<Image x:Name="CamImageDisplay"
DockPanel.Dock="Left"
Source="{Binding CurrentImage, Mode=OneWay}"
Stretch="None" Width="Auto"/>
<Rectangle Width="10" Height="5"
Fill="CadetBlue"
Panel.ZIndex="2" />
</DockPanel>
</Canvas>
I come from an MFC background where drawing shapes on bitmaps was as
easy as calling Draw3dRect(...). Having said that, my goal is to draw
a collection of shapes (just rectangles & circles) that will have
different co ordinates with each new image.
Could some one please
explain in simple terms or point to some reference that will show how
I can achieve this. Yes, there are other similar questions, but they
are really not quite aligned with my objectives. Thank you & please ask for clarifications if I am unclear in how I have asked my question.
Currently i am designing WPF application using MahApps.Metro style UI.
Tile control which provided by MahApps can not showing icon in center of tile
I saw example in MahApps website where it could show image as tile background, but I couldn't figure out how to show icon instead of image (icon such as IE logo, people logo, maps logo, etc)
I appreciated if someone can show me how to do this
Thank you
i figure it out
use icons.xaml as resource, and add rectangle control inside tile, here is the example on how to show character inside tile control
<Controls:Tile x:Name="mahTileExit" Background="Green" Foreground="Yellow" Title="Exit" Width="100" Height="100" TiltFactor ="4" Margin="936,404,0,0" VerticalAlignment="Top" HorizontalAlignment="Left">
<Rectangle Fill="White" Height="45" Width="45">
<Rectangle.OpacityMask>
<VisualBrush Visual="{StaticResource appbar_door_leave}" Stretch="Fill" />
</Rectangle.OpacityMask>
</Rectangle>
</Controls:Tile>
thank you if anyone notice about this, hope can help to contribute
You can use FontAwesome.Wpf which has more icons and requires less code.
<Controls:Tile Width="300" Height="150" Grid.Column="0" Grid.Row="1" Title="Hello!">
<Grid Width="50" Height="50">
<fa:ImageAwesome Icon="Flag" Foreground="#FFFFFF"/>
</Grid>
</Controls:Tile>
Don't forget to call the namespace
xmlns:fa="http://schemas.fontawesome.io/icons/"
I am using Gridsplitter control to give the flexibility of resizing the heights of a grid and a tab in a MVVM driven WPF application.
It is working with out any problem, but after I resize the height of any of the controls I navigate to some other screen and comes back to this screen I am losing the changes. The controls are again reset to their default heights.
Can somebody suggest me an efficient way of restoring the changes when we come back ?
This is the code I am using.
<igDP:XamDataGrid Grid.Row="1" Grid.Column="0" DockPanel.Dock="Top" />
<GridSplitter Grid.Row="2" HorizontalAlignment="Stretch"
VerticalAlignment="Center" Height="2"/>
<TabControl Grid.Row="3" Grid.Column="0" DockPanel.Dock="Top">
Thanks in advance.
First it would be nice to see actual code you can do that by pasting some code in your question and the use cyrly brackets under the yellow banner when you start typing ;-).
Secondly It seems like you could use binding with your ViewModel i.e. VM.UserSettings.TabHeight.
and then in .xaml
this is assuming
<Page or Window.DataContext>
<vm:ViewModel />
</Page or Window.DataContext>
<TabControl Height={Binding UserSettings.TabHeight}">
good luck :-)
Here's my layout.
<Window>
<StackPanel Orientation="Vertical">
<StackPanel HorizontalAlignment="Stretch" Height="30">
</StackPanel>
<Canvas HorizontalAlignment="Center" Width="1020">
<!--i want this to take the remaining full height of the screen-->
<Canvas x:Name="bottomInfoBar" Canvas.Bottom="0" Width="720" Height="39">
<!--I want this at the very bottom of the screen-->
</Canvas>
</Canvas>
</Window>
I want the canvas to take the full height of the window so that the 'bottomInfoBar' always remains at the very bottom of the user's screen. However if i don't specify a height for the canvas 'bottomInfoBar' appears at the very top. How do i achieve this? Please help.
Easiest way:
<Window>
<DockPanel>
<Whatever x:Name="bottomInfoBar" DockPanel.Dock="Bottom"/>
<PrimaryContent/>
</DockPanel>
</Window>
Based on your question, you really should read about WPF's layout system before you write another line of code. You'll save yourself a world of pain if you understand that before proceeding.
I have a Canvas element, contained within a ScrollViewer, which I'm zooming using ScaleTransform. However, I want to be able to keep the scroll position of the viewer focused on the same part of the canvas after the zoom operation has finished. Currently when I zoom the canvas the scroll position of the viewer stays where it was and the place the user was viewing is lost.
I'm still learning WPF, and I've been going backwards and forwards a bit on this, but I can't figure out a nice XAML based way to accomplish what I want. Any help in this matter would be greatly appreciated and would aid me in my learning process.
Here is the kind of code I'm using...
<Grid>
<ScrollViewer Name="TrackScrollViewer" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
<Canvas Width="2560" Height="2560" Name="TrackCanvas">
<Canvas.LayoutTransform>
<ScaleTransform ScaleX="{Binding ElementName=ZoomSlider, Path=Value}"
ScaleY="{Binding ElementName=ZoomSlider, Path=Value}"/>
</Canvas.LayoutTransform>
<!-- Some complex geometry describing a motor racing circuit -->
</Canvas>
</ScrollViewer>
<StackPanel Orientation="Horizontal" Margin="8" VerticalAlignment="Top" HorizontalAlignment="Left">
<Slider Name="ZoomSlider" Width="80" Minimum="0.1" Maximum="10" Value="1"/>
<TextBlock Margin="4,0,0,0" VerticalAlignment="Center" Text="{Binding ElementName=ZoomSlider, Path=Value, StringFormat=F1}"/>
</StackPanel>
</Grid>
This is not a purely XAML way of doing it, but there is a very nice piece of work on Joeyw's blog titled Pan and Zoom (DeepZoom style) in WPF with links to the source. He has taken some inspiration from DeepZoom and it gives you smooth/animated panning and zooming of content. And if you're using WPF 4 you could probably modify it a little to add some easing functions to the animations to give it an even nicer feel.