In my program there is a standard keyboard that I use for the "Entry"
However I'm testing some things and I ended up putting IsEnabled = True, but when the program goes into Focus on that Entry, the default Android Softkeyboard appears, and I do not want it to appear when I click on Entry.
How do I not display the SoftKeyboard in Entry?
<Label Text="CÓD VENDEDOR:"
FontSize="Large"
FontAttributes="Bold"
TextColor="Black"/>
<Entry Placeholder="000000000000000"
Text="{Binding codVend}"
Keyboard="numeric"
MaxLength="15"
FontSize="Large"
FontAttributes="Bold"
IsEnabled="True"
TextColor="Black"
InputTransparent="False"/>
<Label Text="N LÓGICO:"
FontSize="Large"
FontAttributes="Bold"
TextColor="Black"/>
<Entry Placeholder="00000000"
Text="{Binding codTrn}"
Keyboard="Numeric"
MaxLength="8"
IsEnabled="True"
FontSize="Large"
FontAttributes="Bold"
TextColor="Black"
InputTransparent="False"/>
<StackLayout Padding="2"
HorizontalOptions="Center"
VerticalOptions="Center">
<ActivityIndicator IsVisible="{Binding IsBusy}"
IsRunning="{Binding IsBusy}"
Color="Blue"/>
<!-- Place new controls here -->
<StackLayout HorizontalOptions="Center"
VerticalOptions="Center"
Padding="5">
<Grid HorizontalOptions="Center"
VerticalOptions="Center">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="60"/>
<ColumnDefinition Width="60"/>
<ColumnDefinition Width="60"/>
<ColumnDefinition Width="60"/>
</Grid.ColumnDefinitions>
<!--Row 1-->
<Button Text="1"
BackgroundColor="Blue"
TextColor="White"
BorderRadius="10"
Grid.Column="0"
Grid.Row="0"
HeightRequest="60"
FontSize="Large"
FontAttributes="Bold"
HorizontalOptions="Center"
VerticalOptions="Center"
Command="{Binding NumericCommand}"
CommandParameter="1"/>
<Button Text="2"
BackgroundColor="Blue"
TextColor="White"
BorderRadius="10"
Grid.Column="1"
Grid.Row="0"
HeightRequest="60"
FontSize="Large"
FontAttributes="Bold"
HorizontalOptions="Center"
VerticalOptions="Center"
Command="{Binding NumericCommand}"
CommandParameter="2"/>
<Button Text="3"
BackgroundColor="Blue"
TextColor="White"
BorderRadius="10"
Grid.Column="2"
Grid.Row="0"
HeightRequest="60"
FontSize="Large"
FontAttributes="Bold"
HorizontalOptions="Center"
VerticalOptions="Center"
Command="{Binding NumericCommand}"
CommandParameter="3"/>
<Button Text="OK"
BackgroundColor="Green"
TextColor="White"
BorderRadius="10"
Grid.Column="3"
Grid.Row="0"
HeightRequest="60"
FontSize="Large"
FontAttributes="Bold"
HorizontalOptions="Center"
Grid.RowSpan="4"
Command="{Binding SaveCommand}"/>
<!--Row 2-->
<Button Text="4"
BackgroundColor="Blue"
TextColor="White"
BorderRadius="10"
Grid.Column="0"
Grid.Row="1"
HeightRequest="60"
FontSize="Large"
FontAttributes="Bold"
HorizontalOptions="Center"
VerticalOptions="Center"
Command="{Binding NumericCommand}"
CommandParameter="4"/>
<Button Text="5"
BackgroundColor="Blue"
TextColor="White"
BorderRadius="10"
Grid.Column="1"
Grid.Row="1"
HeightRequest="60"
FontSize="Large"
FontAttributes="Bold"
HorizontalOptions="Center"
VerticalOptions="Center"
Command="{Binding NumericCommand}"
CommandParameter="5"/>
<Button Text="6"
BackgroundColor="Blue"
TextColor="White"
BorderRadius="10"
Grid.Column="2"
Grid.Row="1"
HeightRequest="60"
FontSize="Large"
FontAttributes="Bold"
HorizontalOptions="Center"
VerticalOptions="Center"
Command="{Binding NumericCommand}"
CommandParameter="6"/>
<!--Row 3-->
<Button Text="7"
BackgroundColor="Blue"
TextColor="White"
BorderRadius="10"
Grid.Column="0"
Grid.Row="2"
HeightRequest="60"
FontSize="Large"
FontAttributes="Bold"
HorizontalOptions="Center"
VerticalOptions="Center"
Command="{Binding NumericCommand}"
CommandParameter="7"/>
<Button Text="8"
BackgroundColor="Blue"
TextColor="White"
BorderRadius="10"
Grid.Column="1"
Grid.Row="2"
HeightRequest="60"
FontSize="Large"
FontAttributes="Bold"
HorizontalOptions="Center"
VerticalOptions="Center"
Command="{Binding NumericCommand}"
CommandParameter="8"/>
<Button Text="9"
BackgroundColor="Blue"
TextColor="White"
BorderRadius="10"
Grid.Column="2"
Grid.Row="2"
HeightRequest="60"
FontSize="Large"
FontAttributes="Bold"
HorizontalOptions="Center"
VerticalOptions="Center"
Command="{Binding NumericCommand}"
CommandParameter="9"/>
<!--Row 4-->
<Button Text="X"
BackgroundColor="Red"
TextColor="White"
BorderRadius="10"
Grid.Column="0"
Grid.Row="3"
HeightRequest="60"
FontSize="Large"
FontAttributes="Bold"
HorizontalOptions="Center"
VerticalOptions="Center"
Command="{Binding ClearAllCommand}"/>
<Button Text="0"
BackgroundColor="Blue"
TextColor="White"
BorderRadius="10"
Grid.Column="1"
Grid.Row="3"
HeightRequest="60"
FontSize="Large"
FontAttributes="Bold"
VerticalOptions="Center"
Command="{Binding NumericCommand}"
CommandParameter="0"/>
<Button Text="C"
BackgroundColor="Yellow"
TextColor="White"
BorderRadius="10"
Grid.Column="2"
Grid.Row="3"
HeightRequest="60"
FontSize="Large"
FontAttributes="Bold"
HorizontalOptions="Center"
Command="{Binding ClearCommand}"/>
</Grid>
</StackLayout>
</StackLayout>
</StackLayout>
</ContentPage.Content>
Customizing an Entry in Native android can do this:
First, creating a MyEntry
public class MyEntry : Entry
{
}
Second ,using in Xaml:
<ContentPage ...
xmlns:local="clr-namespace:CustomRenderer;assembly=CustomRenderer"
...>
...
<local:MyEntry Text="In Shared Code" />
...
</ContentPage>
Third, modify in Renderer on Android
using Xamarin.Forms.Platform.Android;
[assembly: ExportRenderer(typeof(MyEntry), typeof(MyEntryRenderer))]
namespace CustomRenderer.Android
{
class MyEntryRenderer : EntryRenderer
{
public MyEntryRenderer(Context context) : base(context)
{
}
protected override void OnElementChanged(ElementChangedEventArgs<Entry> e)
{
base.OnElementChanged(e);
if (Control != null)
{
Control.InputType = Android.Text.InputTypes.Null;
//Set input type be null, keyboard will never appear,even when click the Entry.If need show keyboard, this way also can be used.
//Control.InputType = Android.Text.InputTypes.ClassText;
}
}
}
}
Related
New to Powershell, Xaml and coding in general.
Thanks to StackOverflow, I've build a Grid in Powershell with 10 Columns and 8 Rows and fill it with 80 Buttons (From 1 to 80). Each button will trigger an action.
Now, I would like to have the chance to Click on 1 of these buttons and overlap new buttons (or a whole new Grid) on top of the principal Grid in orther to have more buttons available (From 81 to 160).
To make a clear example:
Let's imagine I'm building an App to make orders in the restaurant.
Grid 1 Show 80 buttons.
If I press the "Main Course" button, it will overlay the 80 buttons containing the 80 differents "Main Course". The same if I press "Dessert" buttons ect.
I understood to use the expression Panel.ZIndex="n" and actually work if I code it in Powershell.
<Button Name="Cell2" Grid.Row="0" Grid.Column="1" Opacity="1" Background="#eae0f5" FontFamily="Impact" FontSize="25" Foreground="White" Content="UP" Panel.ZIndex="1"/>
<Button Name="Cell81" Grid.Row="0" Grid.Column="1" Opacity="1" Background="#dfd1f0" FontFamily="Impact" FontSize="25" Foreground="White" Content="DOWN" Panel.ZIndex="0"/>
But when I want to trigger it with a click button like so:
$WPFCell1.add_Click({$WPFCell81.Panel.ZIndex ="2"})
it returns with the following error:
The property 'ZIndex' cannot be found on this object. Verify that the property exists and can be set.
At line:149 char:22
+ $WPFCell1.add_Click({$WPFCell81.Panel.ZIndex ="2"})
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound
Where should I add the Porperty ZIndex if this is the error?
I know probably there are different way to setup this things, but I would like to find a way to make it happen with this code couse again, I'm a noob, and I'm working with a Library that work with this kind of code.
Many thanks to all of you!
This is the whole code if can halp:
#MultiView click overlay
$inputXML = #"
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Name="Window"
WindowStyle = "None" WindowState="Maximized"
ResizeMode = "NoResize" Title = "overlay" AllowsTransparency = "True" Background = "Transparent" Opacity = "1" Topmost = "True">
<Grid x:Name = "Grid" Background = "Transparent" ShowGridLines="False">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="96" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="96" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="55" />
<RowDefinition Height="190" />
<RowDefinition Height="190" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="*" />
<RowDefinition Height="55" />
</Grid.RowDefinitions>
<Button Name="Cell1" Grid.Row="0" Grid.Column="0" Opacity="1" Background="#eae0f5" FontFamily="Impact" FontSize="25" Foreground="White" Content="MENU"/>
<Button Name="Cell2" Grid.Row="0" Grid.Column="1" Opacity="1" Background="#dfd1f0" FontFamily="Impact" FontSize="25" Foreground="White" Content="UP" Panel.ZIndex ="1"/>
<Button Name="Cell3" Grid.Row="0" Grid.Column="2" Opacity="1" Background="#d4c1eb" FontFamily="Impact" FontSize="25" Foreground="White" Content="3"/>
<Button Name="Cell4" Grid.Row="0" Grid.Column="3" Opacity="1" Background="#c9b2e6" FontFamily="Impact" FontSize="25" Foreground="White" Content="4"/>
<Button Name="Cell5" Grid.Row="0" Grid.Column="4" Opacity="1" Background="#bfa3e1" FontFamily="Impact" FontSize="25" Foreground="White" Content="4"/>
<Button Name="Cell6" Grid.Row="0" Grid.Column="5" Opacity="1" Background="#b493dc" FontFamily="Impact" FontSize="25" Foreground="White" Content="5"/>
<Button Name="Cell7" Grid.Row="0" Grid.Column="6" Opacity="1" Background="#a984d7" FontFamily="Impact" FontSize="25" Foreground="White" Content="6"/>
<Button Name="Cell8" Grid.Row="0" Grid.Column="7" Opacity="1" Background="#9f74d2" FontFamily="Impact" FontSize="25" Foreground="White" Content="7"/>
<Button Name="Cell9" Grid.Row="0" Grid.Column="8" Opacity="1" Background="#9465cd" FontFamily="Impact" FontSize="25" Foreground="White" Content="8"/>
<Button Name="Cell10" Grid.Row="0" Grid.Column="9" Background="#f75590" FontFamily="Impact" FontSize="25" Foreground="White" Content="9" />
<Button Name="Cell11" Grid.Row="1" Grid.Column="0" Opacity="1" Background="#dfd1f0" FontFamily="Impact" FontSize="25" Foreground="White" Content="10"/>
<Button Name="Cell12" Grid.Row="1" Grid.Column="1" Opacity="0.01"/>
<Button Name="Cell13" Grid.Row="1" Grid.Column="2" Opacity="0.01"/>
<Button Name="Cell14" Grid.Row="1" Grid.Column="3" Opacity="0.01"/>
<Button Name="Cell15" Grid.Row="1" Grid.Column="4" Opacity="1" Background="#8956c8" FontFamily="Impact" FontSize="25" Foreground="White" Content="14"/>
<Button Name="Cell16" Grid.Row="1" Grid.Column="5" Opacity="1" Background="Yellow" FontFamily="Impact" FontSize="25" Foreground="White" Content="15"/>
<Button Name="Cell17" Grid.Row="1" Grid.Column="6" Opacity="0.01"/>
<Button Name="Cell18" Grid.Row="1" Grid.Column="7" Opacity="0.01"/>
<Button Name="Cell19" Grid.Row="1" Grid.Column="8" Opacity="0.01"/>
<Button Name="Cell20" Grid.Row="1" Grid.Column="9" Opacity="1" Background="#8956c8" FontFamily="Impact" FontSize="25" Foreground="White" Content="20"/>
<Button Name="Cell21" Grid.Row="2" Grid.Column="0" Opacity="1" Background="#cae916" FontFamily="Impact" FontSize="28" Foreground="White" Content="21"/>
<Button Name="Cell22" Grid.Row="2" Grid.Column="1" Opacity="0.01"/>
<Button Name="Cell23" Grid.Row="2" Grid.Column="2" Opacity="0.01"/>
<Button Name="Cell24" Grid.Row="2" Grid.Column="3" Opacity="0.01"/>
<Button Name="Cell25" Grid.Row="2" Grid.Column="4" Opacity="0.01"/>
<Button Name="Cell26" Grid.Row="2" Grid.Column="5" Opacity="0.01"/>
<Button Name="Cell27" Grid.Row="2" Grid.Column="6" Opacity="0.01"/>
<Button Name="Cell28" Grid.Row="2" Grid.Column="7" Opacity="0.01"/>
<Button Name="Cell29" Grid.Row="2" Grid.Column="8" Opacity="0.01"/>
<Button Name="Cell30" Grid.Row="2" Grid.Column="9" Opacity="1" Background="#cae916" FontFamily="Impact" FontSize="28" Foreground="White" Content="30"/>
<Button Name="Cell31" Grid.Row="3" Grid.Column="0" Opacity="1" Background="#c9b2e6" FontFamily="Impact" FontSize="30" Foreground="White" Content="31"/>
<Button Name="Cell32" Grid.Row="3" Grid.Column="1" Opacity="0.01"/>
<Button Name="Cell33" Grid.Row="3" Grid.Column="2" Opacity="0.01"/>
<Button Name="Cell34" Grid.Row="3" Grid.Column="3" Opacity="0.01"/>
<Button Name="Cell35" Grid.Row="3" Grid.Column="4" Opacity="0.01"/>
<Button Name="Cell36" Grid.Row="3" Grid.Column="5" Opacity="0.01"/>
<Button Name="Cell37" Grid.Row="3" Grid.Column="6" Opacity="0.01"/>
<Button Name="Cell38" Grid.Row="3" Grid.Column="7" Opacity="0.01"/>
<Button Name="Cell39" Grid.Row="3" Grid.Column="8" Opacity="0.01"/>
<Button Name="Cell40" Grid.Row="3" Grid.Column="9" Opacity="1" Background="#6a37a9" FontFamily="Impact" FontSize="30" Foreground="White" Content="40"/>
<Button Name="Cell41" Grid.Row="4" Grid.Column="0" Opacity="1" Background="#bfa3e1" FontFamily="Impact" FontSize="30" Foreground="White" Content="41"/>
<Button Name="Cell42" Grid.Row="4" Grid.Column="1" Opacity="0.01"/>
<Button Name="Cell43" Grid.Row="4" Grid.Column="2" Opacity="0.01"/>
<Button Name="Cell44" Grid.Row="4" Grid.Column="3" Opacity="0.01"/>
<Button Name="Cell45" Grid.Row="4" Grid.Column="4" Opacity="0.01"/>
<Button Name="Cell46" Grid.Row="4" Grid.Column="5" Opacity="0.01"/>
<Button Name="Cell47" Grid.Row="4" Grid.Column="6" Opacity="0.01"/>
<Button Name="Cell48" Grid.Row="4" Grid.Column="7" Opacity="0.25" Background="#0000ffff" FontFamily="Impact" FontSize="20" Foreground="White" Content="48"/>
<Button Name="Cell49" Grid.Row="4" Grid.Column="8" Opacity="0.25" Background="#0000ffff" FontFamily="Impact" FontSize="20" Foreground="White" Content="49"/>
<Button Name="Cell50" Grid.Row="4" Grid.Column="9" Opacity="1" Background="#61329a" FontFamily="Impact" FontSize="25" Foreground="White" Content="50"/>
<Button Name="Cell51" Grid.Row="5" Grid.Column="0" Opacity="1" Background="#b493dc" FontFamily="Impact" FontSize="30" Foreground="White" Content="51"/>
<Button Name="Cell52" Grid.Row="5" Grid.Column="1" Opacity="0.01"/>
<Button Name="Cell53" Grid.Row="5" Grid.Column="2" Opacity="0.01"/>
<Button Name="Cell54" Grid.Row="5" Grid.Column="3" Opacity="0.01"/>
<Button Name="Cell55" Grid.Row="5" Grid.Column="4" Opacity="0.01"/>
<Button Name="Cell56" Grid.Row="5" Grid.Column="5" Opacity="1" Background="#a984d7" FontFamily="Impact" FontSize="28" Foreground="White" Content="56"/>
<Button Name="Cell57" Grid.Row="5" Grid.Column="6" Opacity="1" Background="#9f74d2" FontFamily="Impact" FontSize="25" Foreground="White" Content="57"/>
<Button Name="Cell58" Grid.Row="5" Grid.Column="7" Opacity="1" Background="#cae916" FontFamily="Impact" FontSize="35" Foreground="White" Content="58"/>
<Button Name="Cell59" Grid.Row="5" Grid.Column="8" Opacity="1" Background="#f75590" FontFamily="Impact" FontSize="30" Foreground="White" Content="59"/>
<Button Name="Cell60" Grid.Row="5" Grid.Column="9" Opacity="1" Background="#4d287b" FontFamily="Impact" FontSize="20" Foreground="White" Content="60"/>
<Button Name="Cell61" Grid.Row="6" Grid.Column="0" Opacity="1" Background="#cae916" FontFamily="Impact" FontSize="60" Foreground="White" Content="61"/>
<Button Name="Cell62" Grid.Row="6" Grid.Column="1" Opacity="0.01"/>
<Button Name="Cell63" Grid.Row="6" Grid.Column="2" Opacity="0.01"/>
<Button Name="Cell64" Grid.Row="6" Grid.Column="3" Opacity="0.01"/>
<Button Name="Cell65" Grid.Row="6" Grid.Column="4" Opacity="0.01"/>
<Button Name="Cell66" Grid.Row="6" Grid.Column="5" Opacity="1" Background="#bfa3e1" FontFamily="Impact" FontSize="25" Foreground="White" Content="66"/>
<Button Name="Cell67" Grid.Row="6" Grid.Column="6" Opacity="1" Background="#a984d7" FontFamily="Impact" FontSize="25" Foreground="White" Content="67"/>
<Button Name="Cell68" Grid.Row="6" Grid.Column="7" Opacity="1" Background="#9465cd" FontFamily="Impact" FontSize="25" Foreground="White" Content="68"/>
<Button Name="Cell69" Grid.Row="6" Grid.Column="8" Opacity="1" Background="#a984d7" FontFamily="Impact" FontSize="30" Foreground="White" Content="69"/>
<Button Name="Cell70" Grid.Row="6" Grid.Column="9" Opacity="1" Background="#cae916" FontFamily="Impact" FontSize="45" Foreground="White" Content="70"/>
<Button Name="Cell71" Grid.Row="7" Grid.Column="0" Opacity="1" Background="#9f74d2" FontFamily="Impact" FontSize="25" Foreground="White" Content="71"/>
<Button Name="Cell72" Grid.Row="7" Grid.Column="1" Opacity="1" Background="#9465cd" FontFamily="Impact" FontSize="25" Foreground="White" Content="72"/>
<Button Name="Cell73" Grid.Row="7" Grid.Column="2" Opacity="1" Background="#8956c8" FontFamily="Impact" FontSize="25" Foreground="White" Content="73"/>
<Button Name="Cell74" Grid.Row="7" Grid.Column="3" Opacity="1" Background="#773dbd" FontFamily="Impact" FontSize="25" Foreground="White" Content="74"/>
<Button Name="Cell75" Grid.Row="7" Grid.Column="4" Opacity="1" Background="#6a37a9" FontFamily="Impact" FontSize="25" Foreground="White" Content="75"/>
<Button Name="Cell76" Grid.Row="7" Grid.Column="5" Opacity="1" Background="#61329a" FontFamily="Impact" FontSize="25" Foreground="White" Content="76"/>
<Button Name="Cell77" Grid.Row="7" Grid.Column="6" Opacity="1" Background="#4d287b" FontFamily="Impact" FontSize="25" Foreground="White" Content="77"/>
<Button Name="Cell78" Grid.Row="7" Grid.Column="7" Opacity="1" Background="#44236c" FontFamily="Impact" FontSize="25" Foreground="White" Content="78"/>
<Button Name="Cell79" Grid.Row="7" Grid.Column="8" Opacity="1" Background="#3a1e5c" FontFamily="Impact" FontSize="25" Foreground="White" Content="79"/>
<Button Name="Cell80" Grid.Row="7" Grid.Column="9" Opacity="1" Background="#30194d" FontFamily="Impact" FontSize="25" Foreground="White" Content="80"/>
<Button Name="Cell81" Grid.Row="0" Grid.Column="1" Opacity="1" Background="#8956c8" FontFamily="Impact" FontSize="25" Foreground="White" Content="DOWN" Panel.ZIndex ="0"/>
</Grid>
</Window>
"#
$inputXML = $inputXML -replace 'mc:Ignorable="d"','' -replace "x:N",'N' -replace '^<Win.*', '<Window'
[void][System.Reflection.Assembly]::LoadWithPartialName('presentationframework')
[xml]$XAML = $inputXML
#Read XAML
$reader=(New-Object System.Xml.XmlNodeReader $xaml)
try{$Window=[Windows.Markup.XamlReader]::Load( $reader )}
catch [System.Management.Automation.MethodInvocationException] {
Write-Warning "We ran into a problem with the XAML code. Check the syntax for this control..."
write-host $error[0].Exception.Message -ForegroundColor Red
if ($error[0].Exception.Message -like "*button*"){
write-warning "Ensure your <button in the `$inputXML does NOT have a Click=ButtonClick property. PS can't handle this`n`n`n`n"}
}
catch{#if it broke some other way :D
Write-Host "Unable to load Windows.Markup.XamlReader. Double-check syntax and ensure .net is installed."
}
# Create PowerShell object for each WPF button
$xaml.SelectNodes("//*[#Name]") | %{Set-Variable -Name "WPF$($_.Name)" -Value $Window.FindName($_.Name)}
# Map multiview window click to actual
function buttonclicked($btnNAme){
write-host $btnNAme
switch($btnNAme){
0{$Script:Window.close();break
}
}
}
$WPFCell1.add_Click({$WPFCell16.Panel.ZIndex ="1"})
# Turn on WPF overlay display
$Window.ShowDialog() | out-null
Just found a workaround to get the same results with .Visibility "Hidden" or "Visible".
Same structure, same use of Panel.Zindex="n" but instead of modifying the ZIndex value with the button, I hide or show the layer on top.
But I'm sure there is a more convinient way to act, so if you have the solution, pleaseeee :).
Cheers,
M
I seem to be unable to auto-resize an AvalonDock control when its host window is resized. (In addition, the control should dock to the full window at startup, which is also eluding me.)
I've tried the HorizontalAlignment and VerticalAlignment properties, as advised here and several other places here on SO, but they're not working for this control. No control resizing takes place when the window is resized.
From the sound of it, the properties govern resizing a control for its child controls. However, I need to resize the control with its parent (the window).
Here's my XAML, copied from the Xceed sample and modified slightly to run in my environment:
<Window
x:Class="Docker"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:xcad="http://schemas.xceed.com/wpf/xaml/avalondock"
xmlns:s="clr-namespace:System;assembly=mscorlib"
Title="AvalonDock">
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0"
Text="Usage:"
Style="{StaticResource Header}" />
<StackPanel Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<xcad:DockingManager x:Name="_dockingManager"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
AllowMixedOrientation="True"
BorderBrush="Gray"
BorderThickness="1">
<xcad:DockingManager.DocumentHeaderTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Image Source="{Binding IconSource}"
Margin="0,0,4,0" />
<TextBlock Text="{Binding Title}" />
</StackPanel>
</DataTemplate>
</xcad:DockingManager.DocumentHeaderTemplate>
<xcad:LayoutRoot x:Name="_layoutRoot">
<xcad:LayoutPanel Orientation="Horizontal">
<xcad:LayoutAnchorablePane DockWidth="200">
<xcad:LayoutAnchorable ContentId="properties"
Title="Properties"
CanHide="False"
CanClose="False"
AutoHideWidth="240"
IconSource="..\Images\table-gear.png">
<xctk:PropertyGrid NameColumnWidth="110"
SelectedObject="{Binding ElementName=_layoutRoot, Path=LastFocusedDocument.Content}"
AutoGenerateProperties="False">
<xctk:PropertyGrid.PropertyDefinitions>
<xctk:PropertyDefinition TargetProperties="Background" />
<xctk:PropertyDefinition TargetProperties="BorderBrush" />
<xctk:PropertyDefinition TargetProperties="BorderThickness" />
<xctk:PropertyDefinition TargetProperties="FontSize" />
<xctk:PropertyDefinition TargetProperties="FontStyle" />
<xctk:PropertyDefinition TargetProperties="Width" />
<xctk:PropertyDefinition TargetProperties="Height" />
</xctk:PropertyGrid.PropertyDefinitions>
</xctk:PropertyGrid>
</xcad:LayoutAnchorable>
</xcad:LayoutAnchorablePane>
<xcad:LayoutDocumentPaneGroup>
<xcad:LayoutDocumentPane>
<xcad:LayoutDocument ContentId="document1"
Title="Document 1"
IconSource="..\Images\document.png">
<Button Content="Document 1 Content"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
</xcad:LayoutDocument>
<xcad:LayoutDocument ContentId="document2"
Title="Document 2"
IconSource="..\Images\document.png">
<TextBox Text="Document 2 Content"
AcceptsReturn="True" />
</xcad:LayoutDocument>
</xcad:LayoutDocumentPane>
</xcad:LayoutDocumentPaneGroup >
<xcad:LayoutAnchorablePaneGroup DockWidth="125">
<xcad:LayoutAnchorablePane>
<xcad:LayoutAnchorable ContentId="alarms"
Title="Alarms"
IconSource="..\Images\alarm.png"
CanClose="True">
<ListBox>
<s:String>Alarm 1</s:String>
<s:String>Alarm 2</s:String>
<s:String>Alarm 3</s:String>
</ListBox>
</xcad:LayoutAnchorable>
<xcad:LayoutAnchorable ContentId="journal"
Title="Journal">
<RichTextBox>
<FlowDocument>
<Paragraph FontSize="14"
FontFamily="Segoe">
This is the content of the Journal Pane.
<LineBreak />
A
<Bold>RichTextBox</Bold> has been added here
</Paragraph>
</FlowDocument>
</RichTextBox>
</xcad:LayoutAnchorable>
</xcad:LayoutAnchorablePane>
</xcad:LayoutAnchorablePaneGroup>
</xcad:LayoutPanel>
<xcad:LayoutRoot.LeftSide>
<xcad:LayoutAnchorSide>
<xcad:LayoutAnchorGroup>
<xcad:LayoutAnchorable Title="Agenda"
ContentId="agenda"
IconSource="..\Images\book_open.png">
<TextBlock Text="Agenda Content"
Margin="10"
FontSize="18"
FontWeight="Black"
TextWrapping="Wrap" />
</xcad:LayoutAnchorable>
<xcad:LayoutAnchorable Title="Contacts"
ContentId="contacts"
IconSource="..\Images\address_book-edit.png">
<TextBlock Text="Contacts Content"
Margin="10"
FontSize="18"
FontWeight="Black"
TextWrapping="Wrap" />
</xcad:LayoutAnchorable>
</xcad:LayoutAnchorGroup>
</xcad:LayoutAnchorSide>
</xcad:LayoutRoot.LeftSide>
</xcad:LayoutRoot>
</xcad:DockingManager>
<StackPanel Orientation="Horizontal"
HorizontalAlignment="Center">
<Button Content="Save AvalonDock"
Margin="5"
Padding="5"
Click="SaveButton_Click" />
<Button Content="Load AvalonDock"
Margin="5"
Padding="5"
Click="LoadButton_Click" />
</StackPanel>
</StackPanel>
</Grid>
</Window>
Get rid of the StackPanel on the second row of the Grid. A StackPanel doesn't resize its children.
Also note that the default values of the HorizontalAlignment and the VerticalAlignment of a Grid are both Stretch so you don't need to set these explicitly.
Try this:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="Usage:" Style="{StaticResource Header}" />
<xcad:DockingManager x:Name="_dockingManager"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
AllowMixedOrientation="True"
Grid.Row="1"
BorderBrush="Gray"
BorderThickness="1">
<xcad:DockingManager.DocumentHeaderTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Image Source="{Binding IconSource}"
Margin="0,0,4,0" />
<TextBlock Text="{Binding Title}" />
</StackPanel>
</DataTemplate>
</xcad:DockingManager.DocumentHeaderTemplate>
<xcad:LayoutRoot x:Name="_layoutRoot">
<xcad:LayoutPanel Orientation="Horizontal">
<xcad:LayoutAnchorablePane DockWidth="200">
<xcad:LayoutAnchorable ContentId="properties"
Title="Properties"
CanHide="False"
CanClose="False"
AutoHideWidth="240"
IconSource="..\Images\table-gear.png">
<xctk:PropertyGrid NameColumnWidth="110"
SelectedObject="{Binding ElementName=_layoutRoot, Path=LastFocusedDocument.Content}"
AutoGenerateProperties="False">
<xctk:PropertyGrid.PropertyDefinitions>
<xctk:PropertyDefinition TargetProperties="Background" />
<xctk:PropertyDefinition TargetProperties="BorderBrush" />
<xctk:PropertyDefinition TargetProperties="BorderThickness" />
<xctk:PropertyDefinition TargetProperties="FontSize" />
<xctk:PropertyDefinition TargetProperties="FontStyle" />
<xctk:PropertyDefinition TargetProperties="Width" />
<xctk:PropertyDefinition TargetProperties="Height" />
</xctk:PropertyGrid.PropertyDefinitions>
</xctk:PropertyGrid>
</xcad:LayoutAnchorable>
</xcad:LayoutAnchorablePane>
<xcad:LayoutDocumentPaneGroup>
<xcad:LayoutDocumentPane>
<xcad:LayoutDocument ContentId="document1"
Title="Document 1"
IconSource="..\Images\document.png">
<Button Content="Document 1 Content"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
</xcad:LayoutDocument>
<xcad:LayoutDocument ContentId="document2"
Title="Document 2"
IconSource="..\Images\document.png">
<TextBox Text="Document 2 Content"
AcceptsReturn="True" />
</xcad:LayoutDocument>
</xcad:LayoutDocumentPane>
</xcad:LayoutDocumentPaneGroup >
<xcad:LayoutAnchorablePaneGroup DockWidth="125">
<xcad:LayoutAnchorablePane>
<xcad:LayoutAnchorable ContentId="alarms"
Title="Alarms"
IconSource="..\Images\alarm.png"
CanClose="True">
<ListBox>
<s:String>Alarm 1</s:String>
<s:String>Alarm 2</s:String>
<s:String>Alarm 3</s:String>
</ListBox>
</xcad:LayoutAnchorable>
<xcad:LayoutAnchorable ContentId="journal"
Title="Journal">
<RichTextBox>
<FlowDocument>
<Paragraph FontSize="14"
FontFamily="Segoe">
This is the content of the Journal Pane.
<LineBreak />
A
<Bold>RichTextBox</Bold> has been added here
</Paragraph>
</FlowDocument>
</RichTextBox>
</xcad:LayoutAnchorable>
</xcad:LayoutAnchorablePane>
</xcad:LayoutAnchorablePaneGroup>
</xcad:LayoutPanel>
<xcad:LayoutRoot.LeftSide>
<xcad:LayoutAnchorSide>
<xcad:LayoutAnchorGroup>
<xcad:LayoutAnchorable Title="Agenda"
ContentId="agenda"
IconSource="..\Images\book_open.png">
<TextBlock Text="Agenda Content"
Margin="10"
FontSize="18"
FontWeight="Black"
TextWrapping="Wrap" />
</xcad:LayoutAnchorable>
<xcad:LayoutAnchorable Title="Contacts"
ContentId="contacts"
IconSource="..\Images\address_book-edit.png">
<TextBlock Text="Contacts Content"
Margin="10"
FontSize="18"
FontWeight="Black"
TextWrapping="Wrap" />
</xcad:LayoutAnchorable>
</xcad:LayoutAnchorGroup>
</xcad:LayoutAnchorSide>
</xcad:LayoutRoot.LeftSide>
</xcad:LayoutRoot>
</xcad:DockingManager>
<StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Center">
<Button Content="Save AvalonDock"
Margin="5"
Padding="5"
Click="SaveButton_Click" />
<Button Content="Load AvalonDock"
Margin="5"
Padding="5"
Click="LoadButton_Click" />
</StackPanel>
</Grid>
In the XAML below, the first toolbar (Toolbar1 below) does not lose focus and traverses all elements even with KeyboardNavigation.TabNavigation="Once" set. The only way I have make it work is by putting all elements of the toolbar into another container such as stack panel or grid (Toolbar2 below). However, then overflow functionality does not work appropriately. When width is reduced, whole inside container overflows instead of individual items.
My requirement is to tab out from the toolbar after first element (for remaining items user will use the arrow keys) without losing the overflow functionality of overflowing individual items as needed.
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="600" Width="525">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="50" />
<RowDefinition Height="50" />
<RowDefinition Height="100" />
<RowDefinition Height="50" />
<RowDefinition Height="100" />
<RowDefinition Height="50" />
</Grid.RowDefinitions>
<TextBox Grid.Row="0" Text="First" Width="600"></TextBox>
<TextBox Grid.Row="1" Text="Second" Width="600"></TextBox>
<DockPanel LastChildFill="True" Grid.Row="2" Background="Red" >
<ToolBar x:Name="Toolbar1" DockPanel.Dock="Top"
VerticalAlignment="Top" HorizontalAlignment="Stretch" Height="40" BandIndex="1" Band="1"
KeyboardNavigation.TabNavigation="Once" >
<Button Background="Red" Content="1" Height="28" Width="28" ToolBar.OverflowMode="AsNeeded" />
<Button Background="Red" Content="2" Height="28" Width="28" ToolBar.OverflowMode="AsNeeded" />
<Button Background="Red" Content="3" Height="28" Width="28" ToolBar.OverflowMode="AsNeeded" />
<Button Background="Red" Content="4" Height="28" Width="28" ToolBar.OverflowMode="AsNeeded" />
<Button Background="Red" Content="5" Height="28" Width="28" ToolBar.OverflowMode="AsNeeded" />
</ToolBar>
<TextBox DockPanel.Dock="Bottom" Text="I'm first Rich Text Box, My toolbar is not in a inner container." Height="50" Width="600"></TextBox>
</DockPanel>
<TextBox Grid.Row="3" Text="Third" Width="600"></TextBox>
<DockPanel LastChildFill="True" Grid.Row="4" Background="Green">
<ToolBar x:Name="Toolbar2" DockPanel.Dock="Top"
VerticalAlignment="Top" HorizontalAlignment="Stretch" Height="40" BandIndex="1" Band="1"
KeyboardNavigation.TabNavigation="Once" >
<StackPanel Orientation="Horizontal" KeyboardNavigation.TabNavigation="Once" >
<Button Background="Green" Content="1" Height="28" Width="28" ToolBar.OverflowMode="AsNeeded" />
<Button Background="Green" Content="2" Height="28" Width="28" ToolBar.OverflowMode="AsNeeded"/>
<Button Background="Green" Content="3" Height="28" Width="28" ToolBar.OverflowMode="AsNeeded"/>
<Button Background="Green" Content="4" Height="28" Width="28" ToolBar.OverflowMode="AsNeeded"/>
<Button Background="Green" Content="5" Height="28" Width="28" ToolBar.OverflowMode="AsNeeded"/>
</StackPanel>
</ToolBar>
<TextBox DockPanel.Dock="Bottom" Text="I'm second Rich Text Box, My toolbar is in a inner container." Height="50" Width="600"></TextBox>
</DockPanel>
<TextBox Grid.Row="5" Text="Fourth" Width="600"></TextBox>
</Grid>
As I get correct you should turn off FocusManager.IsFocusScope attached property for your ToolBar1, don't I?
i have added two buttons in stackpanel and set alignment as shown in the code
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
<Button Content="Button" Height="64" Name="button1" Width="160" HorizontalAlignment="Left" VerticalAlignment="Top"/>
<Button Content="Button" Height="64" Name="button2" Width="160" HorizontalAlignment="Right" VerticalAlignment="Top"/>
</StackPanel>
but this doesn't match with my requirement. I want it to be like shown in image below.
So how can i do this?
Something like this:
<Grid
Width="480">
<Grid.ColumnDefinitions>
<ColumnDefinition
Width="*" />
<ColumnDefinition
Width="*" />
</Grid.ColumnDefinitions>
<Button
Width="200"
Content="Clear" />
<Button
Grid.Column="1"
Width="200"
Content="Options"
HorizontalAlignment="Right"
/>
</Grid>
UPDATE: Due to popular demand, here is a grid without the fixed width or the columns.
<Grid>
<Button
Width="150"
Content="Clear"
HorizontalAlignment="Left"
/>
<Button
Width="150"
Content="Options"
HorizontalAlignment="Right"
/>
</Grid>
Thats my code so far which does not work:
<DockPanel >
<Button Content="Start" Command="{Binding Path=FirstDateCommand}" />
<Button Content="Back" Command="{Binding Path=PreviousDateCommand}" />
<DatePicker Width="150"
SelectedDate="{Binding Path=SelectedDate}"
DisplayDateStart="{Binding Path=MinDate}"
DisplayDateEnd="{Binding Path=MaxDate}" SelectedDateFormat="Long" />
<Button Content="Forward" Command="{Binding Path=NextDateCommand}" />
<Button Content="End" Command="{Binding Path=LastDateCommand}" />
<Button Command="{Binding PrintCommand}" Content="Print Planner" />
<Button Command="{Binding ToggleDocumentsCommand}" Content="Show Docs" />
<Button Command="{Binding MaterialExplorerShowCommand}" Content="Browse Docs" />
<Button Command="{Binding LessonPlannerCommand}" Content="Edit Planner" />
<TextBox Text="{Binding SearchText,Mode=TwoWay}" Width="50" />
<Button Command="{Binding FindAllCommand}" Content="Search" />
<DockPanel DockPanel.Dock="Right" HorizontalAlignment="Right">
<TextBlock Text="class code:" VerticalAlignment="Center" />
<ComboBox
ItemsSource="{Binding GroupViewModelList}"
Style="{StaticResource GroupViewModelStyle}"
ItemTemplate="{StaticResource GroupViewModelItemTemplate}"
Width="100"/>
</DockPanel>
</DockPanel>
How can I set the 2 last controls on the image on the very right side?
UPDATE:
<Grid Name="MainGrid">
<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid Margin="10,10,10,0" Grid.Row="0" Name="ButtonBar">
<StackPanel FocusManager.IsFocusScope="True" Orientation="Horizontal">
<ComboBox
AlternationCount="2"
FontSize="16"
VerticalContentAlignment="Center"
Width="100"
ItemContainerStyle="{StaticResource alternateColor}"
ItemsSource="{Binding Source={x:Static Member=Fonts.SystemFontFamilies}}" x:Name="fontComboFast">
<ComboBox.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel VirtualizingStackPanel.VirtualizationMode="Recycling" />
</ItemsPanelTemplate>
</ComboBox.ItemsPanel>
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Width="100" Text="{Binding}" FontFamily="{Binding }" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<!--<View:FormatButtonBar />-->
<View:DateNavigatorView />
<View:LessonPlannerView />
<!--<View:TextFormatBarUC />-->
</StackPanel>
</Grid>
The 2 controls are in the LessonPlannerView (UserControl)
Inside the LessonPlannerView you find this code:
...
<Grid >
<DockPanel>
<Button Command="{Binding PrintCommand}" Content="Print Planner" />
<Button Command="{Binding ToggleDocumentsCommand}" Content="Show Docs" />
<Button Command="{Binding MaterialExplorerShowCommand}" Content="Browse Docs" />
<Button Command="{Binding LessonPlannerCommand}" Content="Edit Planner" />
<TextBox Text="{Binding SearchText,Mode=TwoWay}" Width="50" />
<Button Command="{Binding FindAllCommand}" Content="Search" />
<StackPanel x:Name="ClassCodeChooser" Orientation="Horizontal" DockPanel.Dock="Right" HorizontalAlignment="Right">
<TextBlock Text="class code:" VerticalAlignment="Center" />
<ComboBox ItemsSource="{Binding SchoolclassCodeList}"
/>
</StackPanel>
</DockPanel>
</Grid>
</UserControl>
That should be fine but you really don't need the nested DockPanel's. You could change the inner DockPanel to a horizontal StackPanel.
But the real problem is that your outer DockPanel doesn't seem to be expanding to the full width of its container. Set a Background on the outer DockPanel to give you a visual indication of why it isn't filling out its container.
In response to the comment thread below, adding the following example
<Grid Name="ButtonBar">
<Grid.RowDefinitions>
<RowDefinition Height="40" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<DockPanel Grid.Row="0">
<View:FormatButtonBar /> <!-- this will dock left -->
<View:DateNavigatorView /> <!-- this will dock left -->
<View:LessonPlannerView /> <!-- this will dock left -->
<View:TextFormatBarUC /> <!-- this will fill -->
</DockPanel>
</Grid>