Behold the following XAML:
<Grid>
<HyperlinkButton x:Name="Link" Background="Green">
<Grid Background="Red">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="12" />
</Grid.RowDefinitions>
<Image x:Name="AvatarImage" Style="{StaticResource AvatarStyle}" Grid.Column="0" Grid.Row="0" />
<StackPanel Grid.Column="1" HorizontalAlignment="Stretch">
<TextBlock Text="New Topic" Style="{StaticResource ItemTypeStyle}" />
<TextBlock x:Name="Title" Style="{StaticResource HeadlineStyle}" TextWrapping="Wrap" />
<TextBlock x:Name="SubText" Style="{StaticResource TextStyle}" TextWrapping="Wrap" />
</StackPanel>
<TextBlock x:Name="TimeStampText" Grid.ColumnSpan="2" Grid.Row="1" Style="{StaticResource TimeStampStyle}" />
</Grid>
</HyperlinkButton>
In the user control's Loaded event, I call the following code:
var imageUrl = new Uri("http://coasterbuzz.com/Forums/UserAvatar.ashx?id=2");
AvatarImage.Source = new BitmapImage(imageUrl);
Looking at Firebug, the image is coming down the wire, but for some reason it's not displayed. Any guesses as to why? You'd probably like to see the styles, but note that if I remove the styles, nothing changes.
Ah, easy answer. Silverlight 2 doesn't support GIF.
There is a handful of solutions to convert the image serverside here: http://silverlight.net/forums/t/3883.aspx
The most official reason I can find:
Why the support for displaying a .gif
image is is missing? When it will be
added?
We don’t want to take the hit for
another codec. It may only be a little
bit of download time—but our mandate
is small and fast and every little bit
counts. We are also hesitant to
support .gif because it implies
support for animated .gif, which we
decided would have to be integrated
into our animation scheme somehow—and
that will be a lot of work.
Looking from Flash perspective, Flash
does not support .gif either. However,
as of present, this is something being
evaluated, but no date has been
announced
http://blogs.msdn.com/ashish/archive/2008/04/03/silverlight-roadmap-questions.aspx
Related
I am working on a Xamarin.Forms app for a warehouse, we use the Zebra TC25, which has a build in barcode scanner. The scanner works fine and delivers codes.
I have a grid, as shown below, and I want to move the focus to the next text-field (Entry) after a scan has occured. Now I have a callback method which gets triggered after a scan has happened.
My question: How can I have an elegant way of knowing which element has focus and which should be the next?
I have tried using TabIndex - it was ignored.
I have tried giving them names just like below, and then use a dictionary, which maps each Entry-element to the next one to be focused. There I had to iterate over the Keys, and then call something like _focusOrder[entry].Focus();, which is also not the most pretty solution. Specially considering that there are going to be a few forms with more that just 3 codes to be scanned.
Note: The scanner is implemented as a keyboard, and I don't have to set the value from the scanner in my callback - it just works out-of-the-box. Therefore I don't keep track on the focused item, as it is not necessary (for the input).
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Label Grid.Row="0" Grid.Column="0" Text="Von" />
<Entry Grid.Row="0" Grid.Column="1" Text="{Binding Path=VonLagerplatz}" x:Name="_vonEntry" />
<Label Grid.Row="1" Grid.Column="0" Text="Nach" />
<Entry Grid.Row="1" Grid.Column="1" Text="{Binding Path=NachLagerplatz}" x:Name="_nachEntry" />
<Label Grid.Row="2" Grid.Column="0" Text="Artikel" />
<Entry Grid.Row="2" Grid.Column="1" Text="{Binding Path=Artikel}" x:Name="_artikelEntry" />
</Grid>
Optimal solutions: (which I could not make work, cause it is my first Xamarin app)
Make the TabIndex-property work.
Use an attached property, where I can reference the next element in XAML. So have something like <Entry .... x:Name="_vonEntry" NextElement="{Reference _nachEntry}" />
One way to approach this would be to write a custom behaviour that you attach to your entries. Something like this:
<Entry x:Name="VonEntry" Grid.Row="0" Grid.Column="1">
<Entry.Behaviors>
<custom:NextElementOnReturn Element="{x:Reference NachEntry}" />
</Entry.Behaviors>
</Entry>
<Entry x:Name="NachEntry" Grid.Row="1" Grid.Column="1" />
You would have to implement the behaviour NextElementOnReturn by yourself. As far as I know there's nothing builtin.
There's a nice tutorial about behaviours here to get you startet https://blog.xamarin.com/extend-xamarin-forms-controls-functionality-with-behaviors/
I have developed an UWP app allowing users to edit forms.
I would like to use a RelativePanel to show messages to the users on the Home page.
Theses message can concern forms management ("The form XXX has well been deleted", "The form XXX has well been saved"), or the synchronization ("Sync ended successfully", "Impossible to sync datas").
The Home page is based on a Grid that contains 3 rows:
a filter searchbox
the list of the forms
sync informations
Here is a screenshot of this page:
I would like to display the RelativePanel in the 3rd Row, above the sync informations, but only during 2 seconds. Then the RelativePanel will disappear, and the sync informations must be visible again.
I also encounter a problem with the width of the RelativePanel: I would like a left/right padding of 150, but it doesn't seem to work:
My XAML code looks like this:
<!-- User + Last sync-->
<Grid Grid.Row="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding CurrentUser.username}" />
<StackPanel Grid.Column="1"
Orientation="Horizontal"
HorizontalAlignment="Right">
<TextBlock x:Uid="HomeTextBlockLastSync" Margin="0,0,8,0"/>
<TextBlock Text="{Binding LastSync, Mode=TwoWay}" />
</StackPanel>
</Grid>
<!-- Form Status message -->
<RelativePanel Grid.Row="2"
Background="Cyan"
Padding="150,0,150,0">
<StackPanel x:Name="FormStatusPanel" Orientation="Vertical"
RelativePanel.AlignHorizontalCenterWithPanel="True"
RelativePanel.AlignVerticalCenterWithPanel="True">
<Border x:Name="FormStatusBorder" Margin="0">
<ScrollViewer VerticalScrollMode="Auto"
VerticalScrollBarVisibility="Auto"
MaxHeight="150">
<TextBlock Text="TestTestTest"
x:Name="FormStatusBlock" FontWeight="Bold"
TextWrapping="Wrap" />
</ScrollViewer>
</Border>
</StackPanel>
</RelativePanel>
=> Would you have an idea on why the Padding doesn't work? What is a better way to hide RelativePanel after 2 seconds? With the VisualStateManager or by the code?
I've been looking on Google and all over the place for the answer on this, but I'm coming up empty.
I'm trying to make a few windows on my Windows universal app software. I want it to be able to resize itself as the user makes the window bigger or smaller. I can't find anywhere on the properties where it says anchor, and I'm not finding any help with the auto complete with the .xaml.
Any help on this will be welcome
UPDATE for – Justin XL or anyone that can answer
Below is a image of what I'm seeing. I'm trying to get all 4 blocks to take equal space at any given time. Obviously that isn't what I'm getting.
Anyways, I hope you can take a quick look at the code below the picture to tell me what I'm doing wrong.
The code below is what I'm using. I'm not sure if I'm doing something wrong since this is my first Windows app.
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid Background="Gainsboro" Grid.Column="1" Width="Auto" Height="Auto">
<Button x:Name="Click_Me" Grid.Column="1" Content="Click Me" HorizontalAlignment="Center" VerticalAlignment="Center" Click="Click_Me_Click" Width="107" /></Grid>
<Grid Background="Gainsboro" Grid.Column="1" Grid.Row="1" Width="Auto" Height="Auto">
<TextBlock x:Name="textBlock" HorizontalAlignment="Center" TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Center" Grid.Row='1'/></Grid>
<Rectangle Fill="Gainsboro" Width="8" Margin="622,0,10,0" VerticalAlignment="Stretch"/>
<Grid Grid.Column="0">
<WebView Name="Video" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Width="Auto" Height="Auto" Grid.Row="0" Grid.Column="0" />
</Grid>
First, you should remove HorizontalAlignment="Left" on your MySplitView to make the content fill the entire page.
Also, I would change your hard-coded Margin on the Rectangle to -
<Rectangle Fill="Gainsboro" Width="8" VerticalAlignment="Stretch" HorizontalAlignment="Right" Margin="0,0,-4,0" />
Note the -4px(right margin) here. It's because the Rectangle itself is 8px wide and aligned on the edge of the first cell in the Grid, so I shifted it to the right by 4px to make it absolutely sit in the middle of the page.
Hope this helps!
I have created a Windows Store App with the default Hub Project, and on the first hubsection, I have an image as the background. I want to position some text at the bottom of the image to describe what the image is. However I am having trouble position the text inside the Hubsection.contenttemplate.
As you will be able to see from the code I have tried several things including trying to set the vertical alignment of both the grid and the individual text blocks, but neither seems to be working for me.
The code I currently have can be found below.
<HubSection Width="780">
<HubSection.Background>
<ImageBrush ImageSource="Assets/Images/example_meal.png" Stretch="UniformToFill" />
</HubSection.Background>
<HubSection.ContentTemplate>
<DataTemplate>
<Grid Margin="80,0,0,0" VerticalAlignment="Bottom">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock VerticalAlignment="Bottom" x:Name="pageTitle" Text="Primary Text" Style="{StaticResource TitleTextStyle}"
TextWrapping="NoWrap" FontSize="30" Margin="0,0,0,0" />
<TextBlock Grid.Row="1" FontWeight="Bold" Style="{StaticResource BodyTextBlockStyle}" Text="Secondary Text" TextWrapping="Wrap"/>
</Grid>
</DataTemplate>
</HubSection.ContentTemplate>
</HubSection>
I want to display two columns in my Grid. The first is a textblock that is sometimes longer than the row meant to hold it. The second is a button. Is there a way to give the textblock as much room as possible while still leaving room for the button to go immediately after?
When I use the following code, the textblock will sometimes push the button outside the viewable area of the grid.
<Grid >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="{Binding Description}" HorizontalAlignment="Stretch" />
<Button Margin="4,0" Height="0" Width="16" Grid.Column="1" MinWidth="20" VerticalAlignment="Center" />
</Grid>
I've tried setting the first column definition Width="*", but then the button is always at the very end of the row, when I want it next to the text. Any suggestions?
This is in Silverlight 4.
Thanks.
EDIT
I want the grid to resize as the user changes the window size, so setting a hard limit on the grid size is no good. That being said, I was able to manually set the MaxWidth in the code behind when the TextBlock loads and when the window changes size. It's clunky, but it works.
Following will surely work..
<Grid x:Name="LayoutRoot" Background="White" Width="250">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TextBlock x:Name="textBlock" Grid.Column="0" Text="Text Box" VerticalAlignment="Top"/>
<Button x:Name="button" Grid.Column="1" Content="Button" VerticalAlignment="Top" Width="60"/>
</Grid>
Add Following Line to xaml.cs file in constructor..
public MainPage()
{
InitializeComponent();
textBlock.MaxWidth = LayoutRoot.Width - button.Width;
}
Let me know if there is any issue with it.
Thanks..