Answer the question
In order to leave comments, you need to log in
Visual C# 2010 Express "Object reference does not point to an instance of an object."
Please help me find the error. I've been digging for half a day now. Occurs when a Button is clicked.
I bring the code
namespace HS_Conf
{
/// <summary>
/// Логика взаимодействия для MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void button1_Click(object sender, RoutedEventArgs e)
{
AppBody qw = new AppBody();
string hValuePath = qw.SelectedRule.hPath;
MessageBox.Show(hValuePath);
}
}
public class AppBody
{
public ObservableCollection<T> AppCollection { get; set; }
public AppBody()
{
AppCollection = new ObservableCollection<SomeData>{
new T{Name="BMW", Count=20},
new T{Name="Mercedess", Count=30},
new T{Name="Таврия", Count=200}
};
}
pкшм SomeData selectedRule;
public SomeData SelectedRule
{
get { return selectedRule; }
set { selectedRule = value; }
}
public string rr
{
get { return selectedRule.Name; }
set { selectedRule.Name= value; }
}
}
public class T
{
public string Name { get; set; }
public string Count{ get; set; }
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question