private ObservableCollection <TopicOptionInfo> GetTopicOptionInfoObservablecollection(int count)
        {
            IEnumerable <RadioButton> radiobuttonList = gridOne.Children.OfType <RadioButton>();
            IEnumerable <TopicText>   TopicTextList   = gridOne.Children.OfType <TopicText>();
            ObservableCollection <TopicOptionInfo> topicOptionlist = new ObservableCollection <TopicOptionInfo>();

            foreach (RadioButton item in radiobuttonList)
            {
                TopicOptionInfo topicOptionInfo;
                if (item.Visibility == Visibility.Visible)
                {
                    if (Grid.GetRow(item) <= count)
                    {
                        TopicText model = TopicTextList.FirstOrDefault(p => Grid.GetRow(p) == Grid.GetRow(item));

                        topicOptionInfo       = new TopicOptionInfo();
                        topicOptionInfo.Id    = Grid.GetRow(item);
                        topicOptionInfo.Right = false;
                        if (item.IsChecked == true)
                        {
                            topicOptionInfo.Right = true;
                        }

                        topicOptionInfo.RightVisibility = Visibility.Visible;
                        topicOptionInfo.Title           = model.Text;
                        topicOptionInfo.Index           = Grid.GetRow(item);
                        topicOptionlist.Add(topicOptionInfo);
                    }
                }
            }


            return(topicOptionlist);
        }
Beispiel #2
0
        static void Textchanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            TopicText tt = sender as TopicText;

            tt.Text = e.NewValue.ToString();
            tt.tboxContent.DataContext = tt.DataContext;
        }
        private bool checkContent(int count)
        {
            IEnumerable <RadioButton> radiobuttonList = gridOne.Children.OfType <RadioButton>();
            IEnumerable <TopicText>   TopicTextList   = gridOne.Children.OfType <TopicText>();
            bool Checked = false;

            foreach (RadioButton item in radiobuttonList)
            {
                TopicOptionInfo topicOptionInfo;
                if (item.Visibility == Visibility.Visible)
                {
                    if (!Checked)
                    {
                        if (item.IsChecked == true)
                        {
                            Checked = true;
                        }
                    }
                    if (Grid.GetRow(item) <= count)
                    {
                        TopicText model = TopicTextList.FirstOrDefault(p => Grid.GetRow(p) == Grid.GetRow(item));

                        if (model.Text == "" && model.Text.Trim() == "")
                        {
                            MessageBox.Show("第" + Grid.GetRow(item) + "行的内容不能为空!");
                            return(false);
                        }
                    }
                }
            }
            if (!Checked)
            {
                MessageBox.Show("请您您勾选正确答案!");
            }
            return(Checked);
        }