MahApps Progress Indicator not stretching to content - wpf

I have a MahApps progress indicator declared like this:
<Controls:ProgressIndicator ProgressColour="{StaticResource AccentColorBrush}" Width="600" Height="20" VerticalAlignment="Top" HorizontalAlignment="Stretch"
Visibility="{Binding ElementName=Self, Path=DataContext.ShowProgress, Converter={StaticResource b2v}, FallbackValue=Visible}"/>
And for some reason the indicator bars do not stretch the size of the control. It only fills about 20% of the width. (I can't show a picture as my reputation is too low).
Has anyone experienced this before?
Cheers
Edit
The indicator is on a stackpanel declared like this:
<StackPanel Grid.Column="2" Grid.ColumnSpan="6" Orientation="Vertical">

Update:
In the latest version from nuget or Github ProgressIndicator seems to be removed(cos it was buggy).
Pull request that removed the control early this year
This release, again, contains some breaking changes. We try to break things now rather than later, when we release version 1.0 (which is hopefully soon).
A quick overview:
ProgressIndicator is now removed, as it wasn't working as expected. Use MetroProgressBar with IsIndeterminate = True instead, which should give a much smoother experience.
I just tried the sample with
<Controls:MetroProgressBar Width="300"
Margin="0, 10, 0, 0"
Foreground="{DynamicResource AccentColorBrush}"
IsIndeterminate="True"
Maximum="100"
Minimum="0" />

Related

Restoring layout when we use GridSplitter

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 :-)

WP7 An Image over the full display

I am developing an application where i want to browse images like native WindowsPhone form.
I have used Pivot control. Everything works, but there is one unwanted thing. The image does not fill all display area. There is a gap on the top of page. I have set margin and padding everywhere where it is possible. And the result is still the same. :(
Here is my XAML code:
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid
x:Name="LayoutRoot"
Background="Transparent"
Margin="0">
<toolkit:PerformanceProgressBar
VerticalAlignment="Top"
HorizontalAlignment="Left"
IsIndeterminate="{Binding IsBusy}"
Visibility="{Binding IsBusy, Converter={StaticResource BoolToVisibilityConverter}}"
/>
<controls:Pivot
x:Name="PhotoPivot"
ScrollViewer.HorizontalScrollBarVisibility="Auto"
IsHitTestVisible="True"
ItemsSource="{Binding Photos}"
Margin="0"
Padding="0"
>
<controls:Pivot.HeaderTemplate>
<DataTemplate/>
</controls:Pivot.HeaderTemplate>
<controls:Pivot.ItemTemplate>
<DataTemplate >
<controls:PivotItem
x:Name="PhotoPivotItem"
Margin="0"
>
<Image
x:Name="PhotoPicture"
Source="{Binding}"
Stretch="Uniform"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Margin="0"
/>
</controls:PivotItem>
</DataTemplate>
</controls:Pivot.ItemTemplate>
</controls:Pivot>
</Grid>
Are you talking about the system tray?
To remove the system tray use the following code:
shell:SystemTray.IsVisible="False"
Update:
I'm not real sure why that extra space is there.
I created a simplified version of your example and the only thing I could think of is to use negative margins. There is probably a better solution that I am just overlooking, but for now you can just use the following:
<controls:PivotItem x:Name="PhotoPivotItem" Margin="0,-10,0,0">
Although, from your posted image, it looks as if you have a bigger gap than I did, so you might need to decrease the margin.

Silverlight: why png-image is not displaying?

In Silverlight 4 application there are few images, both are displayed correctly in design mode, one is displayed correctly in run-time also:
<Image Height="180" Width="149" Source="../Picts/Field.png" />
Another one is not displayed in run-time:
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="5" Visibility="{Binding SquadSavedVisibility, Mode=OneWay}">
<Image Source="..\Picts\ok.png" Width="16" Height="16" />
<TextBlock Text=" It is saved" Foreground="Green"/>
</StackPanel>
Why? And how to get it displayed?
Any thoughts are welcome. Thanks.
It's all in your slashes, VS Design time doesn't mind you using "..\Picts\ok.png", but Silverlight runtime wants to see "../Picts/ok.png". In other words, your slashes matter.
I had a similar problem with images showing in design-time, but not at runtime. Mine was using a pack URI so I wanted to post that fix as well:
Does not work at runtime, does work at design-time:
<Image Source="mydllname;component/Images/logo.png" />
Works at both design and runtime:
<Image Source="/mydllName;component/Images/logo.png" />
Note the extra '/' before the Pack URI starts.
You can try to hook into the Image.ImageFailed Event. For examples and more explanation you look into this page:
http://msdn.microsoft.com/en-us/library/system.windows.controls.image.imagefailed%28v=VS.95%29.aspx

Why might a silverlight ListBox on Windows Phone not allow me scroll all the way down to the bottom?

I have a ListBox in a grid that gets databound when the page loads... pretty straightforward. The problem I'm having is that, after the box is databound, I can scroll... but not all the way to the bottom of the list. It stops an item or two short and won't let me scroll anymore. Here's the listbox XAML:
<Grid x:Name="ContentGrid" Grid.Row="2">
<ListBox x:Name="lbFeed" ItemsSource="{Binding Items}" SelectionChanged="lbFeed_SelectionChanged" VerticalAlignment="Top" Width="480">
<ListBox.ItemTemplate>
<DataTemplate x:Key="MyDataTemplate">
<StackPanel Orientation="Vertical" Width="430">
<TextBlock Text="Some text" TextAlignment="Center" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
I can post more code, but I'm still getting my feet wet in XAML and I'm not sure what might be causing this. If you need more context, let me know and I'll add it here.
This is a known issue at this stage of ctp release if you happen to have rows that are not fixed height. If this is the case you will likely notice your scrolling is a bit jittery too. Fix the height of your content for now if this is the case for your app and all is resolved.

WPF: Aligning the base line of a Label and its TextBox

Let's say I have a simple TextBox next to a Label:
<StackPanel>
<StackPanel Orientation="Horizontal">
<Label Margin="3">MyLabel</Label>
<TextBox Margin="3" Width="100">MyText</TextBox>
</StackPanel>
...
</StackPanel>
This yields the following result:
As you can see, the base lines of MyLabel and MyText are not aligned, which looks ugly. Of course, I could start playing around with the margins until they match up, but since this is such a common requirement I'm sure that WPF provides a much easier and more elegant solution, which I just haven't found yet...
This behaviour is, I think, caused by the fact that the TextBox defaults to a vertical alignment of Stretch, which causes it to fill the available space and have the extra couple of pixels under the text. If you use this instead:
<StackPanel>
<StackPanel Orientation="Horizontal">
<Label >MyLabel</Label>
<TextBox VerticalAlignment="Center" Width="100">MyText</TextBox>
</StackPanel>
</StackPanel>
... you should see a cleaner result.
What do you think?
<StackPanel Orientation="Horizontal">
<Label Margin="3" VerticalContentAlignment="Center">MyLabel</Label>
<TextBox Margin="3" VerticalContentAlignment="Center" Width="100">MyText</TextBox>
</StackPanel>
I achieved that look in Kaxaml with:
<StackPanel Orientation="Horizontal">
<Label Margin="3" VerticalAlignment="Center">MyLabel</Label>
<TextBox Margin="3" Width="100" VerticalAlignment="Center">MyText</TextBox>
</StackPanel>
I know that this is an old answer, but for here's an example for those who seek another way, where you don't need to rely on a fixed textbox width:
Instead of StackPanel, use a DockPanel and .Dock.
This proves to be very handy when used inside a Grid.
<DockPanel Grid.Column="2" Grid.Row="2">
<Label Content="SomeTitle:" DockPanel.Dock="Left"></Label>
<TextBox x:Name="SomeValueTextBox" VerticalAlignment="Center" DockPanel.Dock="Right"></TextBox>
</DockPanel>
This question is not as trivial as it looks and the accepted answers lacks details. If you try custom heights with the controls, you will see issues.
First, this is the correct implementation as answered by User7116.
<StackPanel Orientation="Horizontal">
<Label Margin="3" VerticalAlignment="Center">MyLabel</Label>
<TextBox Margin="3" Width="100" VerticalAlignment="Center">MyText</TextBox>
</StackPanel>
The tricky part is that there two level of vertical alignments here so understand how the alignments works.
When we specify alignment for a control, we are telling it how to position itself in the parent container (See documentation). So when we specify VerticalAlignment="Center"> to the TextBox we are telling it that this TextBox should appear vertically centered in parent stackpanel.
Now the actual text inside that TextBox could also use vertical alignment within that TextBox! This is the 2nd level and actually quite tricky and is answered here.
If you experiment with setting the Label's height above to say 50 as well, you will see they will not align again. This is because Label is now taking larger area and its text inside that area is not vertical aligned so it doesn't look aligned again.
The code for above is:
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<Label Margin="3" VerticalAlignment="Center" Height="50">MyLabel</Label>
<TextBox Margin="3" VerticalAlignment="Center" Width="50" Height="50">MyText</TextBox>
</StackPanel>
Luckily when control height is default (like label control), it's just tall enough to contain the text so the inside alignment doesn't matter. But it comes into play if someone is setting custom heights for these controls and its better to understand how this works.

Resources