For some unknown reason people use Regex.
This is a useful link with examples from O'Reilly: Regex 101
12 years ago
One step forward, two steps back
public class MySimpleClass
{
public MySimpleClass()
{
}
}
public class MySimpleClass
{
public MySimpleClass() : base()
{
}
}
which makes a bunch of stuff easier to understand.public class MySimpleClass : MyBaseClass
{
public MySimpleClass() : this(5)
{
}
public MySimpleClass(int x) : base(x)
{
}
}
<DataTemplate x:Key="listBookingTemplate">... <DataTemplate x:Key="listCCardTemplate">... <DataTemplate x:Key="listCashTemplate">...
<DataTemplate x:Key="listDefaultTemplate">...
<ss:TillRollTemplateSelector
BookingTemplate="{StaticResource listBookingTemplate}"
CCardTemplate="{StaticResource listCCardTemplate}"
CashTemplate="{StaticResource listCashTemplate}"
DefaultTemplate="{StaticResource listDefaultTemplate}"
x:Key="tillTemplateSelector" />
<ListBox Name="theTillRoll" Height="250" Width="330"
ItemsSource="{Binding Source={StaticResource ViewModel}, Path=SaleItems}"
ItemTemplateSelector="{StaticResource tillTemplateSelector}"
/>
public class TillRollTemplateSelector : DataTemplateSelector
{
public DataTemplate BookingTemplate { get; set; }
public DataTemplate CashTemplate { get; set; }
public DataTemplate CCardTemplate { get; set; }
public DataTemplate DefaultTemplate { get; set; }
public override DataTemplate SelectTemplate(object item, DependencyObject container)
{
if (item is BookingLineItem) return BookingTemplate;
if (item is CashPaymentLineItem) return CashTemplate;
if (item is CCardPaymentLineItem) return CCardTemplate;
return DefaultTemplate;
}
}
<Button.IsEnabled>
<MultiBinding Converter="{StaticResource loginConverter}">
<Binding ElementName="xSite" Path="SelectedIndex"/>
<Binding ElementName="xUsername" Path="Text"/>
</MultiBinding>
</Button.IsEnabled>
public class LoginConverter : IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
// SelectedIndex of the ComboBox
int selectedIndex = (int)values[0];
// Length of Text in TextBox
int selectedLength = ((string)values[1]).Length;
// Only enable Button if both Combo and TextBox have data
if (selectedIndex == -1 || selectedLength==0)
{
return false;
}
else
{
return true;
}
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}