I have been using MahApp.Metro for a few project now, and WinForms charts too, and also combined them.
So nothing new on that front in this project, except :
The placement of the chart.
And this is causing an issue where the Mahapps.Metro Flyout menu i have opens BEHIND the chart. See Screenshot.
Is there any way to solve this? i have searched a bit and found nothing. In CSS it would be a simple z-index setting... but in C# i have no idea.
Any help appreciated.
XAML as requested :
<Controls:MetroWindow x:Name="wdw_MainWindow" x:Class="AdminProgram.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
xmlns:winformchart="clr-namespace:System.Windows.Forms.DataVisualization.Charting;assembly=System.Windows.Forms.DataVisualization"
xmlns:local="clr-namespace:AdminProgram"
mc:Ignorable="d"
Title="MainWindow" Height="600" Width="1024" GlowBrush="{DynamicResource AccentColorBrush}" WindowStartupLocation="CenterScreen" ResizeMode="NoResize" BorderThickness="2,2,0,2" ShowMinButton="False" ShowMaxRestoreButton="False" IsMinButtonEnabled="False" IsMaxRestoreButtonEnabled="False" BorderBrush="#FF7C7C7C" TitleForeground="White">
<Controls:MetroWindow.Flyouts>
<Controls:FlyoutsControl>
<Controls:Flyout x:Name="fyo_Menu" Header="Menu" Width="200" Theme="Accent">
<Grid>
<Controls:Tile x:Name="btn_AddNew" Title="Add New"
Width="150" Height="150" TitleFontSize="20" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0" Click="btn_AddNew_Click" KeepDragging="False" MouseEnter="Tile_MouseEnter" MouseLeave="Tile_MouseLeave" BorderBrush="#FFC89632">
</Controls:Tile>
<Controls:Tile x:Name="btn_ViewAll" Title="View All"
Width="150" Height="150" TitleFontSize="20" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,160,0,0" Padding="0" Click="btn_ViewAll_Click" MouseEnter="Tile_MouseEnter" MouseLeave="Tile_MouseLeave" BorderBrush="#FFC89632" >
</Controls:Tile>
</Grid>
</Controls:Flyout>
</Controls:FlyoutsControl>
</Controls:MetroWindow.Flyouts>
<GroupBox x:Name="gpb_Home_Stats" Header="Latest information and statistics" Margin="0,50,0,0">
<Grid>
<!--- Winforms Integrated charting -->
<!--Strength bars -->
<WindowsFormsHost x:Name="wfh_Statistics_Strengthometer" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="0,0,0,0" Width="950" Height="425">
<winformchart:Chart x:Name="chart_Strengthometer" Dock="None">
<winformchart:Chart.Legends>
<winformchart:Legend Docking="Left" TitleSeparator="Line" Title="Coffee count by strength"/>
</winformchart:Chart.Legends>
<winformchart:Chart.Series>
<winformchart:Series Name="Strength" ChartType="Column"/>
</winformchart:Chart.Series>
<winformchart:Chart.ChartAreas>
<winformchart:ChartArea/>
</winformchart:Chart.ChartAreas>
</winformchart:Chart>
</WindowsFormsHost>
</Grid>
</GroupBox>
That's a known issue when mixing WinForms and WPF and is not related to MahApps.Metro. Just search for Airspace here at StackOverflow.
Related
Cant make button in WPF app with image and text on it. My code is like this:
<Window x:Class="WindowR.One"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WindowR"
mc:Ignorable="d"
Title="One" Height="300" Width="300">
<Grid>
<StackPanel Orientation="Vertical">
<TextBlock Text="Click Here" />
<Image Source="D:\Skola\4. semester\TP\GIT folder\Visualko\Core\WindowR\Pictures\0.png" />
</StackPanel>
</Grid>
</Window>
But the text isnt above image..tried lots of tutorials from here..but none of them work properly
StackPanel arranges TextBlock next to Image. Try to use Grid
<Button Width="120" Height="50" >
<Grid>
<Image Source="D:\Skola\4. semester\TP\GIT folder\Visualko\Core\WindowR\Pictures\0.png" />
<TextBlock Text="Click Here"
VerticalAlignment="Center"
HorizontalAlignment="Center" />
</Grid>
</Button>
I have a transparent Window which works fine, but a TextBox ignores the ClearType.
The RenderOptions.ClearTypeHint="Enabled" is set but nothing happens. There is no other Effect, OpacityMask, VisualBrush, DrawingBrush, Clip, or Opacity only AllowsTransparency="True" and AllowsTransparency="True".
AllowsTransparency="True"
AllowsTransparency="False" on normal Window
Xaml sample
<Window x:Class="WpfApplication3.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="200"
Width="300"
Title="MainWindow"
AllowsTransparency="True"
WindowStyle="None">
<Window.Template>
<ControlTemplate>
<Grid Background="White"
Height="200"
Width="300"
RenderOptions.ClearTypeHint="Enabled"
TextOptions.TextRenderingMode="ClearType"
TextOptions.TextFormattingMode="Display">
<StackPanel VerticalAlignment="Center"
HorizontalAlignment="Center">
<Label>Lorem Ipsum Test</Label>
<TextBlock>Lorem Ipsum Test</TextBlock>
<TextBox Text="Lorem Ipsum"
Background="White" />
</StackPanel>
</Grid>
</ControlTemplate>
</Window.Template>
</Window>
Any suggestions? Is this a known issue that can not be solved?
UPDATE
With Snoop I see a TextBoxLineDrawingVisual, maybe this is causing the issue?
That's because grid's attached properties for text like "RenderingMode" internally implemented to apply on "textblock" not "textbox" child elements.
I want to use a usercontrol I found on the web in my WPF application. The thing is that I don't want to have to put it in a user control library and build it and then reference that. I just want to be able to import the files into my project and use it from there.
So what I have done is dragged the files into the solution explorer, and it added them okay. I then changed the namespaces to match my own and then attempted to add it to the main forms xaml(This is where my issue is.)
It says the type "local:Pie" is not found. Verify that you are not missing an assembly reference...and you know the rest.
Here is how I am calling it on my main for xaml:
<Grid>
<local:Pie Value="0" x:Name="pieChart" HorizontalAlignment="Center" Width="400" VerticalAlignment="Center" Margin="10"/>
<StackPanel HorizontalAlignment="Left" Margin="30,0,50,0" VerticalAlignment="Center">
<Slider Orientation="Vertical" Minimum="0" Maximum="1" TickFrequency="0.01" Height="272" ValueChanged="Slider_ValueChanged_1" Value="0" Name="slider"/>
</StackPanel>
</Grid>
Here is the controls XAML with my application namespace added:
<UserControl x:Class="MyApplicationNAmespace.Pie"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300" Loaded="UserControl_Loaded_1" SizeChanged="UserControl_SizeChanged_1">
<Grid>
<Ellipse Name="bgCircle"/>
<Path Name="path" StrokeThickness="1.5" Margin="0"/>
<Ellipse Name="hole" RenderTransformOrigin="0.5,0.5">
<Ellipse.RenderTransform>
<ScaleTransform ScaleX="0.45" ScaleY="0.45"/>
</Ellipse.RenderTransform>
</Ellipse>
<Label Content="Value" HorizontalAlignment="Center" VerticalAlignment="Center"
FontFamily="Segoe UI Light" FontSize="38" Name="lblValue"
VerticalContentAlignment="Center" HorizontalContentAlignment="Center"/>
</Grid>
</UserControl>
For the codebehind of the control all I have changed was the namespace to match my projects namespace.
Can anyone tell me what I am doing wrong? Thank you.
I am having a problem with different appearance in Blend/VS2012 IDE and in Debugging.
In IDE, the Rectangle is at the center, but when it is compiled or debugged, the size of the margin is different. In my view, this occurs because the size of the window border is different. I really want to fix this problem. Any suggestions?
Thank You.
XAML
<Window x:Class="WpfApplication2.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="202" Width="194">
<Grid HorizontalAlignment="Left" Height="171" VerticalAlignment="Top" Width="186">
<Rectangle Fill="#FFF4F4F5" HorizontalAlignment="Left" Height="151" Margin="10,10,0,0" Stroke="Black" VerticalAlignment="Top" Width="166"/>
</Grid>
Edited XAML code:
<Window x:Class="WpfApplication2.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="202" Width="194">
<Grid HorizontalAlignment="Left" Height="171" VerticalAlignment="Top" Width="186">
<Rectangle Fill="#FFF4F4F5" HorizontalAlignment="Center" Height="151" Margin="10" Stroke="Black" VerticalAlignment="Center" Width="166"/>
</Grid>
Result is the same. Is this problem of my PC?
Your Problem here is Window Size includes the Chrome Size(Window Border and stuff like close/max min buttons).
Your Grid is hence the size you requested but it does not fit in the window size you've requested.
I could fix your issue to make the output window look like this, with Window size:
Width: 202
Height: 210
on Windows 8
However you should rather have your window size set to SizeToContent="WidthAndHeight"
Example:
<Window x:Class="WpfApplication4.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfApplication4"
x:Name="window"
Title="MainWindow"
SizeToContent="WidthAndHeight">
<Grid HorizontalAlignment="Left" Height="171" VerticalAlignment="Top" Width="186">
<Rectangle Fill="#FFF4F4F5" HorizontalAlignment="Left" Height="151" Margin="10,10,0,0" Stroke="Black" VerticalAlignment="Top" Width="166"/>
</Grid>
</Window>
Your thus not assuming Chrome sizes which might be different from different versions of Windows.
You should also get Snoop. It helps you debug such issues very easily, It shows a red border on a control when you hover on it with Shift+Ctrl, so you can actually see the Grid extend past the visible Window while showing the actual Element Layout of your UI
I been stack for the last few days trying to figure out the SilverLight 4 LineSeries graph, for some strange reason the graph being displayed but the line not being displayed. I am pretty sure that my mistake is something very basic but I been straggling to pinpoint the problem by myself.
Bellow is the code that I having problem with.
<toolkit:Chart HorizontalAlignment="Left" x:Name="chartLine" Margin="31,35,0,0" Title="Chart for test" VerticalAlignment="Top" Height="233" Width="309">
<toolkit:LineSeries IsSelectionEnabled="True" HorizontalAlignment="Left" DependentValuePath="Y" IndependentValuePath="X" Margin="195,49,0,0" Name="lineSeries1" VerticalAlignment="Top" Height="78" Width="130">
<toolkit:LineSeries.ItemsSource>
<PointCollection>
<Point>1,10</Point>
<Point>2,20</Point>
<Point>3,30</Point>
<Point>4,40</Point>
</PointCollection>
</toolkit:LineSeries.ItemsSource>
</toolkit:LineSeries>
</toolkit:Chart>
I would also apreciate if anyone can point me to some code example with scrollable graph on Silverlight.
Thank you in advance.
Here's the corrected XAML. Your problem is the HorizontalAlignment/VerticalAlignment/Margin/Width/Height you have set in the LineSeries. Removing these fixes the problem.
Here's the complete XAML which shows the Chart with the lines properly placed.
<UserControl x:Class="SilverlightApplication1.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:toolkit="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">
<Grid x:Name="LayoutRoot" Background="White">
<toolkit:Chart HorizontalAlignment="Left" x:Name="chartLine" Margin="31,35,0,0" Title="Chart for test" VerticalAlignment="Top" Height="233" Width="309">
<toolkit:LineSeries IsSelectionEnabled="True" DependentValuePath="Y" IndependentValuePath="X" Name="lineSeries1">
<toolkit:LineSeries.ItemsSource>
<PointCollection>
<Point>1,10</Point>
<Point>2,20</Point>
<Point>3,30</Point>
<Point>4,40</Point>
</PointCollection>
</toolkit:LineSeries.ItemsSource>
</toolkit:LineSeries>
</toolkit:Chart>
</Grid>
</UserControl>