-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from AvaloniaUI/master
Merge
- Loading branch information
Showing
55 changed files
with
6,481 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<UserControl xmlns="https://github.com/avaloniaui"> | ||
<StackPanel Orientation="Vertical" Gap="4"> | ||
<TextBlock Classes="h1">AutoCompleteBox</TextBlock> | ||
<TextBlock Classes="h2">A control into which the user can input text</TextBlock> | ||
|
||
<StackPanel Orientation="Horizontal" | ||
Margin="0,16,0,0" | ||
HorizontalAlignment="Center" | ||
Gap="8"> | ||
<StackPanel Orientation="Vertical"> | ||
<TextBlock Text="MinimumPrefixLength: 1"/> | ||
<AutoCompleteBox Width="200" | ||
Margin="0,0,0,8" | ||
MinimumPrefixLength="1"/> | ||
<TextBlock Text="MinimumPrefixLength: 3"/> | ||
<AutoCompleteBox Width="200" | ||
Margin="0,0,0,8" | ||
MinimumPrefixLength="3"/> | ||
<TextBlock Text="MinimumPopulateDelay: 1 Second"/> | ||
<AutoCompleteBox Width="200" | ||
Margin="0,0,0,8" | ||
MinimumPopulateDelay="1"/> | ||
<TextBlock Text="MaxDropDownHeight: 60"/> | ||
<AutoCompleteBox Width="200" | ||
Margin="0,0,0,8" | ||
MaxDropDownHeight="60"/> | ||
<AutoCompleteBox Width="200" | ||
Margin="0,0,0,8" | ||
Watermark="Watermark"/> | ||
<TextBlock Text="Disabled"/> | ||
<AutoCompleteBox Width="200" | ||
IsEnabled="False"/> | ||
</StackPanel> | ||
|
||
|
||
<StackPanel Orientation="Vertical"> | ||
|
||
<TextBlock Text="ValueMemeberSelector"/> | ||
<AutoCompleteBox Width="200" | ||
Margin="0,0,0,8" | ||
ValueMemberSelector="Capital"/> | ||
<TextBlock Text="ValueMemberBinding"/> | ||
<AutoCompleteBox Width="200" | ||
Margin="0,0,0,8" | ||
ValueMemberBinding="{Binding Capital}"/> | ||
<TextBlock Text="Multi-Binding"/> | ||
<AutoCompleteBox Name="MultiBindingBox" | ||
Width="200" | ||
Margin="0,0,0,8" | ||
FilterMode="Contains"/> | ||
<TextBlock Text="Async Populate"/> | ||
<AutoCompleteBox Name="AsyncBox" | ||
Width="200" | ||
Margin="0,0,0,8" | ||
FilterMode="None"/> | ||
</StackPanel> | ||
</StackPanel> | ||
</StackPanel> | ||
</UserControl> |
143 changes: 143 additions & 0 deletions
143
samples/ControlCatalog/Pages/AutoCompleteBoxPage.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
using Avalonia.Controls; | ||
using Avalonia.LogicalTree; | ||
using Avalonia.Markup; | ||
using Avalonia.Markup.Xaml; | ||
using Avalonia.Markup.Xaml.Data; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace ControlCatalog.Pages | ||
{ | ||
public class AutoCompleteBoxPage : UserControl | ||
{ | ||
public class StateData | ||
{ | ||
public string Name { get; private set; } | ||
public string Abbreviation { get; private set; } | ||
public string Capital { get; private set; } | ||
|
||
public StateData(string name, string abbreviatoin, string capital) | ||
{ | ||
Name = name; | ||
Abbreviation = abbreviatoin; | ||
Capital = capital; | ||
} | ||
|
||
public override string ToString() | ||
{ | ||
return Name; | ||
} | ||
} | ||
|
||
private StateData[] BuildAllStates() | ||
{ | ||
return new StateData[] | ||
{ | ||
new StateData("Alabama","AL","Montgomery"), | ||
new StateData("Alaska","AK","Juneau"), | ||
new StateData("Arizona","AZ","Phoenix"), | ||
new StateData("Arkansas","AR","Little Rock"), | ||
new StateData("California","CA","Sacramento"), | ||
new StateData("Colorado","CO","Denver"), | ||
new StateData("Connecticut","CT","Hartford"), | ||
new StateData("Delaware","DE","Dover"), | ||
new StateData("Florida","FL","Tallahassee"), | ||
new StateData("Georgia","GA","Atlanta"), | ||
new StateData("Hawaii","HI","Honolulu"), | ||
new StateData("Idaho","ID","Boise"), | ||
new StateData("Illinois","IL","Springfield"), | ||
new StateData("Indiana","IN","Indianapolis"), | ||
new StateData("Iowa","IA","Des Moines"), | ||
new StateData("Kansas","KS","Topeka"), | ||
new StateData("Kentucky","KY","Frankfort"), | ||
new StateData("Louisiana","LA","Baton Rouge"), | ||
new StateData("Maine","ME","Augusta"), | ||
new StateData("Maryland","MD","Annapolis"), | ||
new StateData("Massachusetts","MA","Boston"), | ||
new StateData("Michigan","MI","Lansing"), | ||
new StateData("Minnesota","MN","St. Paul"), | ||
new StateData("Mississippi","MS","Jackson"), | ||
new StateData("Missouri","MO","Jefferson City"), | ||
new StateData("Montana","MT","Helena"), | ||
new StateData("Nebraska","NE","Lincoln"), | ||
new StateData("Nevada","NV","Carson City"), | ||
new StateData("New Hampshire","NH","Concord"), | ||
new StateData("New Jersey","NJ","Trenton"), | ||
new StateData("New Mexico","NM","Santa Fe"), | ||
new StateData("New York","NY","Albany"), | ||
new StateData("North Carolina","NC","Raleigh"), | ||
new StateData("North Dakota","ND","Bismarck"), | ||
new StateData("Ohio","OH","Columbus"), | ||
new StateData("Oklahoma","OK","Oklahoma City"), | ||
new StateData("Oregon","OR","Salem"), | ||
new StateData("Pennsylvania","PA","Harrisburg"), | ||
new StateData("Rhode Island","RI","Providence"), | ||
new StateData("South Carolina","SC","Columbia"), | ||
new StateData("South Dakota","SD","Pierre"), | ||
new StateData("Tennessee","TN","Nashville"), | ||
new StateData("Texas","TX","Austin"), | ||
new StateData("Utah","UT","Salt Lake City"), | ||
new StateData("Vermont","VT","Montpelier"), | ||
new StateData("Virginia","VA","Richmond"), | ||
new StateData("Washington","WA","Olympia"), | ||
new StateData("West Virginia","WV","Charleston"), | ||
new StateData("Wisconsin","WI","Madison"), | ||
new StateData("Wyoming","WY","Cheyenne"), | ||
}; | ||
} | ||
public StateData[] States { get; private set; } | ||
|
||
public AutoCompleteBoxPage() | ||
{ | ||
this.InitializeComponent(); | ||
|
||
States = BuildAllStates(); | ||
|
||
foreach (AutoCompleteBox box in GetAllAutoCompleteBox()) | ||
{ | ||
box.Items = States; | ||
} | ||
|
||
var converter = new FuncMultiValueConverter<string, string>(parts => | ||
{ | ||
return String.Format("{0} ({1})", parts.ToArray()); | ||
}); | ||
var binding = new MultiBinding { Converter = converter }; | ||
binding.Bindings.Add(new Binding("Name")); | ||
binding.Bindings.Add(new Binding("Abbreviation")); | ||
|
||
var multibindingBox = this.FindControl<AutoCompleteBox>("MultiBindingBox"); | ||
multibindingBox.ValueMemberBinding = binding; | ||
|
||
var asyncBox = this.FindControl<AutoCompleteBox>("AsyncBox"); | ||
asyncBox.AsyncPopulator = PopulateAsync; | ||
} | ||
private IEnumerable<AutoCompleteBox> GetAllAutoCompleteBox() | ||
{ | ||
return | ||
this.GetLogicalDescendants() | ||
.OfType<AutoCompleteBox>(); | ||
} | ||
|
||
private bool StringContains(string str, string query) | ||
{ | ||
return str.IndexOf(query, StringComparison.OrdinalIgnoreCase) >= 0; | ||
} | ||
private async Task<IEnumerable<object>> PopulateAsync(string searchText, CancellationToken cancellationToken) | ||
{ | ||
await Task.Delay(TimeSpan.FromSeconds(1.5), cancellationToken); | ||
|
||
return | ||
States.Where(data => StringContains(data.Name, searchText) || StringContains(data.Capital, searchText)) | ||
.ToList(); | ||
} | ||
|
||
private void InitializeComponent() | ||
{ | ||
AvaloniaXamlLoader.Load(this); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<UserControl xmlns="https://github.com/avaloniaui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> | ||
<StackPanel Orientation="Vertical" Gap="4"> | ||
<TextBlock Margin="2" Classes="h1">Numeric up-down control</TextBlock> | ||
<TextBlock Margin="2" Classes="h2" TextWrapping="Wrap">Numeric up-down control provides a TextBox with button spinners that allow incrementing and decrementing numeric values by using the spinner buttons, keyboard up/down arrows, or mouse wheel.</TextBlock> | ||
|
||
<TextBlock Margin="2,5,2,2" FontSize="14" FontWeight="Bold">Features:</TextBlock> | ||
<Grid Margin="2" ColumnDefinitions="Auto,Auto,Auto,Auto" RowDefinitions="Auto,Auto"> | ||
<Grid Grid.Row="0" Grid.Column="0" ColumnDefinitions="Auto, Auto" RowDefinitions="35,35,35,35,35"> | ||
<TextBlock Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" Margin="2">ShowButtonSpinner:</TextBlock> | ||
<CheckBox Grid.Row="0" Grid.Column="1" IsChecked="{Binding #upDown.ShowButtonSpinner}" VerticalAlignment="Center" Margin="2"/> | ||
|
||
<TextBlock Grid.Row="1" Grid.Column="0" VerticalAlignment="Center" Margin="2">IsReadOnly:</TextBlock> | ||
<CheckBox Grid.Row="1" Grid.Column="1" IsChecked="{Binding #upDown.IsReadOnly}" VerticalAlignment="Center" Margin="2"/> | ||
|
||
<TextBlock Grid.Row="2" Grid.Column="0" VerticalAlignment="Center" Margin="2">AllowSpin:</TextBlock> | ||
<CheckBox Grid.Row="2" Grid.Column="1" IsChecked="{Binding #upDown.AllowSpin}" IsEnabled="{Binding #upDown.!IsReadOnly}" VerticalAlignment="Center" Margin="2"/> | ||
|
||
<TextBlock Grid.Row="3" Grid.Column="0" VerticalAlignment="Center" Margin="2">ClipValueToMinMax:</TextBlock> | ||
<CheckBox Grid.Row="3" Grid.Column="1" IsChecked="{Binding #upDown.ClipValueToMinMax}" VerticalAlignment="Center" Margin="2"/> | ||
|
||
</Grid> | ||
<Grid Grid.Row="0" Grid.Column="1" Margin="10,2,2,2" ColumnDefinitions="Auto, 120" RowDefinitions="35,35,35,35,35"> | ||
<TextBlock Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" Margin="2">FormatString:</TextBlock> | ||
<DropDown Grid.Row="0" Grid.Column="1" Items="{Binding Formats}" SelectedItem="{Binding SelectedFormat}" | ||
VerticalAlignment="Center" Margin="2"> | ||
<DropDown.ItemTemplate> | ||
<DataTemplate> | ||
<StackPanel Orientation="Horizontal" Gap="2"> | ||
<TextBlock Text="{Binding Name}"/> | ||
<TextBlock Text="-"/> | ||
<TextBlock Text="{Binding Value}"/> | ||
</StackPanel> | ||
</DataTemplate> | ||
</DropDown.ItemTemplate> | ||
</DropDown> | ||
|
||
<TextBlock Grid.Row="1" Grid.Column="0" VerticalAlignment="Center" Margin="2">ButtonSpinnerLocation:</TextBlock> | ||
<DropDown Grid.Row="1" Grid.Column="1" Items="{Binding SpinnerLocations}" SelectedItem="{Binding #upDown.ButtonSpinnerLocation}" | ||
VerticalAlignment="Center" Margin="2"/> | ||
|
||
<TextBlock Grid.Row="2" Grid.Column="0" VerticalAlignment="Center" Margin="2">CultureInfo:</TextBlock> | ||
<DropDown Grid.Row="2" Grid.Column="1" Items="{Binding Cultures}" SelectedItem="{Binding #upDown.CultureInfo}" | ||
VerticalAlignment="Center" Margin="2"/> | ||
|
||
<TextBlock Grid.Row="3" Grid.Column="0" VerticalAlignment="Center" Margin="2">Watermark:</TextBlock> | ||
<TextBox Grid.Row="3" Grid.Column="1" Text="{Binding #upDown.Watermark}" VerticalAlignment="Center" Margin="2" /> | ||
|
||
<TextBlock Grid.Row="4" Grid.Column="0" VerticalAlignment="Center" Margin="2">Text:</TextBlock> | ||
<TextBox Grid.Row="4" Grid.Column="1" Text="{Binding #upDown.Text}" VerticalAlignment="Center" Margin="2" /> | ||
</Grid> | ||
<Grid Grid.Row="0" Grid.Column="2" Margin="10,2,2,2" RowDefinitions="35,35,35,35,35" ColumnDefinitions="Auto, 120"> | ||
<TextBlock Grid.Row="0" Grid.Column="0" VerticalAlignment="Center" Margin="10,2,2,2">Minimum:</TextBlock> | ||
<NumericUpDown Grid.Row="0" Grid.Column="1" Value="{Binding #upDown.Minimum}" | ||
CultureInfo="{Binding #upDown.CultureInfo}" VerticalAlignment="Center" Height="25" Margin="2" Width="70" HorizontalAlignment="Center"/> | ||
|
||
<TextBlock Grid.Row="1" Grid.Column="0" VerticalAlignment="Center" Margin="10,2,2,2">Maximum:</TextBlock> | ||
<NumericUpDown Grid.Row="1" Grid.Column="1" Value="{Binding #upDown.Maximum}" | ||
CultureInfo="{Binding #upDown.CultureInfo}" VerticalAlignment="Center" Height="25" Margin="2" Width="70" HorizontalAlignment="Center"/> | ||
|
||
<TextBlock Grid.Row="2" Grid.Column="0" VerticalAlignment="Center" Margin="10,2,2,2">Increment:</TextBlock> | ||
<NumericUpDown Grid.Row="2" Grid.Column="1" Value="{Binding #upDown.Increment}" VerticalAlignment="Center" | ||
Height="25" Margin="2" Width="70" HorizontalAlignment="Center"/> | ||
|
||
<TextBlock Grid.Row="3" Grid.Column="0" VerticalAlignment="Center" Margin="10,2,2,2">Value:</TextBlock> | ||
<NumericUpDown Grid.Row="3" Grid.Column="1" Value="{Binding #upDown.Value}" VerticalAlignment="Center" | ||
Height="25" Margin="2" Width="70" HorizontalAlignment="Center"/> | ||
|
||
</Grid> | ||
</Grid> | ||
|
||
<StackPanel Margin="2,10,2,2" Orientation="Horizontal" Gap="10"> | ||
<TextBlock FontSize="14" FontWeight="Bold" VerticalAlignment="Center">Usage of NumericUpDown:</TextBlock> | ||
<NumericUpDown Name="upDown" Minimum="0" Maximum="10" Increment="0.5" | ||
CultureInfo="en-US" VerticalAlignment="Center" Height="25" Width="100" | ||
Watermark="Enter text" FormatString="{Binding SelectedFormat.Value}"/> | ||
</StackPanel> | ||
|
||
</StackPanel> | ||
</UserControl> |
Oops, something went wrong.