Text Align Left in an autocomplete box - xaml

I am searching how to align left the text in a AutoCompleteBox
So I details,
the result is too long for the textbox associated to autocomplete box, so, there is a missing part.
if the result is : "result of my autocomplete box", when I click and choose it, it's display on the textbox.
But the part display is : "f my autocomplete box", and I want "result of my autocomplete".
Here is my xaml :
<myControl:AutoCompleteBox x:Name="acp" Grid.Row="0" Grid.Column="1"
HorizontalAlignment="Left" VerticalAlignment="Top"
IsTabStop="False"
MinimumPrefixLength="3"
ItemTemplate="{StaticResource ItemTemplate}"
ValueMemberBinding="{Binding FullName}"
ItemsSource="{Binding Data, ElementName=MySource}"
Text="{Binding FullName, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnExceptions=True}"
Width="150"
IsTextCompletionEnabled="False"
FilterMode="None" IsDropDownOpen="True"/>
I hope i'm clear.
Thank you.

you should try This
<my:AutoCompleteBox Name="acbNames" ValueMemberBinding="{Binding FullName}">
<my:AutoCompleteBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding FullName}" TextAlignment="Left"/>
</DataTemplate>
</my:AutoCompleteBox.ItemTemplate>
</my:AutoCompleteBox>

Please use setter property of AutoCompleteBox to set text alignment like follow:
<toolkit:AutoCompleteBox.TextBoxStyle>
<Style TargetType="TextBox">
<Setter Property="TextAlignment" Value="Center"></Setter>
</Style>
</toolkit:AutoCompleteBox.TextBoxStyle>
Thanks...

Take a look at the following url http://social.msdn.microsoft.com/Forums/en-US/silverlightarchieve/thread/d41d201d-834f-4f8a-8b78-122ff08dd830/ this might help.

Related

UWP RelativePanel plan an element right to another then stretch to the panel

This is my XAML
<RelativePanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Margin="10,0,0,0">
<TextBlock x:Name="PageTitle"
RelativePanel.AlignTopWithPanel="True"
Style="{StaticResource WindowTitle}">This is my page title</TextBlock>
<TextBlock x:Name="ActivityLabel"
RelativePanel.Below="PageTitle"
Style="{StaticResource CaptionTitle}">Activity</TextBlock>
<ComboBox x:Name="ActivityOptions"
RelativePanel.RightOf="ActivityLabel"
RelativePanel.AlignRightWithPanel="True"
RelativePanel.AlignHorizontalCenterWith="ActivityLabel"
ItemsSource="{Binding Path=SupportedActivityTypes}">
</ComboBox>
</RelativePanel>
And this is my output
What I want to achieve is that the title is on top of the page, multiple lines below the title. Each line has a caption, right to the caption is combo box, textbox and so on, but the right side should stretch to the right border of the panel.
Obviously my code does not work, the combo does not even central align with my caption text as I specified in markup. And how to make the left side of combo to touch the caption text and right side to the border of the panel?
I figured it out, I need following XAML
<RelativePanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Margin="10,0,0,0">
<TextBlock x:Name="PageTitle"
Margin="0,0,0,20"
RelativePanel.AlignTopWithPanel="True"
Style="{StaticResource WindowTitle}">This is page title</TextBlock>
<TextBlock x:Name="ActivityLabel"
RelativePanel.Below="PageTitle"
Style="{StaticResource CaptionTitle}">Activity</TextBlock>
<ComboBox x:Name="ActivityOptions"
Margin="10,0,0,0"
HorizontalAlignment="Stretch"
RelativePanel.RightOf="ActivityLabel"
RelativePanel.AlignRightWithPanel="True"
RelativePanel.AlignVerticalCenterWith="ActivityLabel"
ItemsSource="{Binding Path=SupportedActivityTypes}">
</ComboBox>
</RelativePanel>
The combo box is on the same line of caption label ("Activity") and meanwhile the width stretches to relative panel size.
how to make the left side of combo to touch the caption text and right side to the border of the panel?
You need to set RelativePanel.RightOf="PageTitle" and RelativePanel.AlignVerticalCenterWith="PageTitle".
<RelativePanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Margin="10,0,0,0">
<TextBlock x:Name="PageTitle"
RelativePanel.AlignTopWithPanel="True"
Style="{StaticResource TitleTextBlockStyle}" VerticalAlignment="Center" FontSize="35">This is my page title</TextBlock>
<TextBlock x:Name="ActivityLabel"
RelativePanel.Below="PageTitle"
Style="{StaticResource CaptionTextBlockStyle}">Activity</TextBlock>
<ComboBox x:Name="ActivityOptions"
RelativePanel.RightOf="PageTitle"
RelativePanel.AlignRightWithPanel="True"
RelativePanel.AlignVerticalCenterWith="PageTitle"
ItemsSource="{Binding Path=SupportedActivityTypes}">
</ComboBox>
</RelativePanel>

How do I create a two column layout using xaml RelativePanel?

I'd really like to use RelativePanel in a UWP app I'm writing, to simplify visual state.
This is what I want
I've tried to achieve this with the following XAML:
<RelativePanel>
<TextBlock x:Name="Title" Height="50" Margin="15" FontSize="24"
RelativePanel.AlignTopWithPanel="True"
RelativePanel.AlignLeftWithPanel="True"
RelativePanel.AlignRightWithPanel="True">
</TextBlock>
<TextBox x:Name="Editor" Margin="15" Padding="20" HorizontalAlignment="Stretch"
RelativePanel.AlignLeftWithPanel="True"
RelativePanel.Below="Title"
RelativePanel.RightOf="FileList">
</TextBox>
<ListView x:Name="FileList" HorizontalAlignment="Stretch" Margin="15"
RelativePanel.AlignRightWithPanel="True"
RelativePanel.Below="Title">
</ListView>
</RelativePanel>
This isn't working. Editor does not stretch. If I set Editor to RelativePanel.AlignRightWith="FilesList", it stretches past files list and fills the window.
Is there any way to do what I want with RelativePanel? Please don't post suggestions on how to do this in Grid, I can already do that - I want to use RelativePanel in this case
Your Editor control should have -
RelativePanel.AlignLeftWithPanel="True"
RelativePanel.Below="Title"
RelativePanel.LeftOf="FileList"
RelativePanel.AlignBottomWithPanel="True"
Note it should be LeftOf, not RightOf. You will also need AlignBottomWithPanel set to True.

ListBox Windows 10 Universal Header

I successfully added a listbox with databinding in my xaml:
But i forgot which attribute to use for the items header. My items contain to Textboxes "name", "money earned" and if i add items my items say for example "Mustermann", "300" but i need a headertemplate above the items which says "name" and "money earned" how do i add such a header for the items?
The xaml I already wrote isn't relevant for this question but if you are interested:
<ListBox x:Name="WorkersList" ItemsSource="{Binding}" MaxWidth="480" MaxHeight="400" VerticalAlignment="Top" HorizontalAlignment="Left">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding name}" HorizontalAlignment="Center" Width="100"></TextBlock>
<TextBlock Text="{Binding gehalt}" HorizontalAlignment="Center" Width="100"></TextBlock>
<ToggleSwitch></ToggleSwitch>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
You could use a ListView with a GridView. In each GridViewColumn, there is a property called Header.
EDIT:
You could use a ListView. Apparently there is a ListView.Header property in W10 apps. Have a look at this. Something like the following could work:
<ListView>
<ListView.Header>
<StackPanel>
<TextBlock Text="Name"/>
<TextBlock Text="Money earned"/>
</StackPanel>
</ListView.Header>
</ListView>
First of all,ListBox doesn't support Header
I'm not sure if i understand your question correctly, but If you mean you wanna have something like Table (have a header and data in it) I suggest you to use some useful classes like MyToolkit (DataGrid)
Helpful question in Stackoverflow

Screen does not display full content of string

i'm using the textblock to display the content,but for the long content, it just cut off and not display the content fully while i'm sure that the i filled the content string. Pls show me where my code is wrong. Thanks
Link of the my screen: www.flickr.com/photos/37903269#N05/15332152972/
my xaml code :
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<!-- <phone:WebBrowser VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Name="webBrowser1" /> -->
<ListBox Name="Listbox_DetailPage">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding Content}"
TextWrapping="Wrap"
Style="{StaticResource PhoneTextNormalStyle}"
HorizontalAlignment="Center"
/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</Grid>
I executed the code shared and it seems to wrap text as shown in the screen shot below.
The screenshot you shared seems to have vertical cropping of the text as well. For that, we can set the ScrollViewer.VerticalScrollBarVisibility to 'Auto' with proper Height given.
Also, for your additional knowledge or may be future use, here are some stackoverflow questions which explains the text 'NOT WRAPPING' issue for StackPanel
TextBlock TextWrapping not wrapping inside StackPanel
TextBlock TextWrapping not wrapping
actually, i fixed it.Because of the limitation of sing UI: 4096px limit of size. So there is a need to split the long content in the more than one TextBlock or you can create a scrollabe textbock as here

Binding Hyperlink to richtextblock in windows 8 Metro app

I am building a windows 8 metro app for fun/learning etc.
I have created a listview of text items that have descriptions, images etc. Inside the description, there are often hyperlinks that I would like to make clickable.
However, when binding to a textblock, xaml hyperlink code is displayed as text. Searching arround, it looks like I need to use a richtextblock for hyperlinks. I can't seem to figure out how to bind a hyperlink to it. I have found many examples from wpf showing how to extend the richtextblock using flowdocument. Flowdocument doesn't exist in the current consumer preview version of the framework.
I am reaching out to see if anyone has solved this issue or has any suggestions on what path to head down.
Edit:
Code I have Currently
right now I am just binding the "text" field from my Statuses Object to a textblock binding on "text"
I have URL's in the text field which I want to be able to make clickable.
As a test I was replacing the text field of the first object with hyperlink markup
ex.
feed_results[0].text = "<hyperlink .....
then trying to bind to texblock and richtextblock
Xaml
<ListView x:Name="ItemListView" ItemsSource="{Binding}" Background="Black" Width="372" VerticalAlignment="Top" Margin="50,0,0,0">
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical" MinHeight="100">
<StackPanel Orientation="Horizontal">
<Image Source="{Binding user.profile_image_url}" Margin="0,0,15,0" VerticalAlignment="Top" />
<StackPanel Orientation="Vertical">
<TextBlock HorizontalAlignment="Left" Foreground="Gray" Text="{Binding user.name}" FontWeight="Bold" TextWrapping="Wrap" MaxWidth="200" />
<TextBlock HorizontalAlignment="Left" Foreground="Gray" Text="{Binding text}" TextWrapping="Wrap" MaxWidth="200" />
</StackPanel>
</StackPanel>
<StackPanel Margin="0,15,0,0" HorizontalAlignment="Right">
<TextBlock Text="{Binding created_at, Converter={StaticResource StringConverter},ConverterParameter=Released: \{0:d\}}" HorizontalAlignment="Center" Foreground="Gray" />
</StackPanel>
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
Backend Code
FeedResult<Statuses> r2 = await feed.StatusesAsync(1, 50);
if (!r2.HasError)
{
feed_results = r2.Result;
Dispatcher.Invoke(Windows.UI.Core.CoreDispatcherPriority.High, new Windows.UI.Core.InvokedHandler((o, a) =>
{
ItemListView1.ItemsSource = feed_results;
}), this, null);
}
Microsoft removed support for inline hyperlinks from Metro XAML. You can still use HyperlinkButton for non inline hyperlinks, or if your inline hyperlinks short (1-2 words) then you could place HyperlinkButton inside of InlineUIContainer in RichTextBlock. Later solution would require some code, just using binding won't do it.