namespace WpfApp2.model
{
public class Spares
{
public string name { get; set; }
public int price { get; set; }
public string detail { get; set; }
public string type { get; set; }
public List<SparesDetail> SparesDetailList { get; set; }
public List<SparesPrice> SparesPriceList { get; set; }
public List<SparesType> SparesTypeList { get; set; }
}
}
namespace WpfApp2.model
{
class Globals
{
public static IDataProvider dataProvider;
}
}
namespace WpfApp2.model
{
public class SparesDetail
{
public string title { get; set; }
}
public class SparesPrice
{
public string title { get; set; }
public int PriceFrom { get; set; }
public int PriceTo { get; set; }
}
public class SparesType
{
public string title { get; set; }
}
}
Mainwindow.xaml( )
</ComboBox>
<RadioButton
GroupName="Price"
Tag="2"
Content=""
Checked="RadioButton_Checked"
VerticalAlignment="Center" RenderTransformOrigin="0.067,0.44"/>
<RadioButton
GroupName="Price"
Tag="1"
Content=""
IsChecked="True"
Checked="RadioButton_Checked"
VerticalAlignment="Center" Height="15" Width="69"/>
<Label
Content=""
VerticalAlignment="Center"/>
<TextBox
Width="200"
VerticalAlignment="Center"
x:Name="SearchFilterTextBox"
KeyUp="SearchFilter_KeyUp"/>
Mainwindow.xaml.cs( )
get
{
var res = _SparesList;
res = res
.Where(c => (c.detail == selectedDetail || selectedDetail == ""))
.Where(c => (selectedPrice == null || (c.price >= selectedPrice.PriceFrom && c.price < selectedPrice.PriceTo)))
.Where(c => (c.type == selectedType || selectedType == " "));
if (searchFilter != "")
res = res.Where(c => c.name.IndexOf(
searchFilter,
StringComparison.OrdinalIgnoreCase) >= 0);
if (sortAsc) res = res.OrderBy(c => c.price);
else res = res.OrderByDescending(c => c.price);
return res;
}
set
{
_SparesList = value;
}
}
private bool sortAsc = true;
private void RadioButton_Checked(object sender, RoutedEventArgs e)
{
sortAsc = (sender as RadioButton).Tag.ToString() == "1";
Invalidate();
}
private void SearchFilter_KeyUp(object sender, KeyEventArgs e)
{
searchFilter = SearchFilterTextBox.Text;
Invalidate();
}