本文整理汇总了C#中System.Windows.Controls.ListBox.UpdateLayout方法的典型用法代码示例。如果您正苦于以下问题:C# ListBox.UpdateLayout方法的具体用法?C# ListBox.UpdateLayout怎么用?C# ListBox.UpdateLayout使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.ListBox
的用法示例。
在下文中一共展示了ListBox.UpdateLayout方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CounterAction
private void CounterAction(DataResult result)
{
this.isSelect = false;
this.selectDataresult = result;
NextStateCode = result.AppState;
List<Rule_UserInfoViewModel> listviewmodel = new List<Rule_UserInfoViewModel>();
result.DictCounterUser.Keys.ForEach(key =>
{
Rule_UserInfoViewModel vm = new Rule_UserInfoViewModel(key, result.DictCounterUser[key].ToList());
listviewmodel.Add(vm);
});
//this.ListCountersign.ItemsSource = listviewmodel;
//AuditEventArgs args = new AuditEventArgs(AuditEventArgs.AuditResult.Error, result);
//args.StartDate = this.AuditEntity.StartDate;
//args.EndDate = System.DateTime.Now;
//OnAuditCompleted(this, args);
//this.BindingData();
DataTemplate CountersignTemplate = this.Resources["CountersignTemplate"] as DataTemplate;
Style listboxStyle = this.Resources["ListBoxItemStyle1"] as Style;
System.Windows.Controls.Window winSelector = new System.Windows.Controls.Window();
winSelector.Unloaded += new RoutedEventHandler(winSelector_Unloaded);
winSelector.MinHeight = 400;
winSelector.Width = 400;
//winSelector.Resources.Add("UserInfoTemplate", this.Resources["UserInfoTemplate"]);
//winSelector.Resources.Add("ListBoxItemStyle1", this.Resources["ListBoxItemStyle1"]);
//winSelector.Resources.Add("CountersignTemplate", this.Resources["CountersignTemplate"]);
//winSelector.Width = 400;
winSelector.TitleContent = "确认审核人";
Grid gridSelector = new Grid();
RowDefinition r1 = new RowDefinition();
RowDefinition r2 = new RowDefinition();
RowDefinition r3 = new RowDefinition();
r1.Height = new GridLength(50, GridUnitType.Auto);
r2.Height = new GridLength(30, GridUnitType.Auto);
r3.Height = new GridLength(50, GridUnitType.Auto);
gridSelector.RowDefinitions.Add(r1);
gridSelector.RowDefinitions.Add(r2);
gridSelector.RowDefinitions.Add(r3);
TextBlock tb = new TextBlock();
tb.Height = 26;
tb.VerticalAlignment = System.Windows.VerticalAlignment.Center;
if (result.CountersignType == "0")
{
tb.Text = "请为每个角色至少选择一人,并按确认提交。";
}
else
{
tb.Text = "请至少选择一人,并按确认提交。";
}
tb.SetValue(Grid.RowProperty, 0);
ScrollViewer sp = new ScrollViewer();
ListBox listboxCountersign = new ListBox();
listboxCountersign.ItemTemplate = CountersignTemplate;
listboxCountersign.ItemContainerStyle = listboxStyle;
listboxCountersign.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Stretch;
listboxCountersign.VerticalAlignment = System.Windows.VerticalAlignment.Top;
sp.SetValue(Grid.RowProperty, 1);
listviewmodel.ForEach(item =>
{
item.ListUserInfo.ForEach(ent =>
{
ent.UserInfo.CompanyName = ent.UserInfo.UserName + "(" + ent.UserInfo.CompanyName + "->" + ent.UserInfo.DepartmentName + "->" + ent.UserInfo.PostName + ")";
});
});
listboxCountersign.ItemsSource = listviewmodel;
sp.Height = 300;
sp.Width = 400;
//listboxCountersign.
//listboxCountersign.ScrollIntoView(listviewmodel);
listboxCountersign.UpdateLayout();
sp.Content=listboxCountersign;
Button btnOK = new Button();
btnOK.Content = "确认";
btnOK.Margin = new Thickness(0, 0, 5, 10);
btnOK.VerticalAlignment = System.Windows.VerticalAlignment.Center;
btnOK.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
btnOK.Width = 80;
btnOK.Height = 26;
btnOK.SetValue(Grid.RowProperty, 2);
btnOK.Click += (o, e) =>
{
this.isSelect = true;
#region
#region Check
this.DictCounterUser = new Dictionary<Role_UserType, ObservableCollection<UserInfo>>();
if (result.CountersignType == "0")
{
foreach (var viewModel in listviewmodel)
{
//.........这里部分代码省略.........
示例2: UpdateLayout
public static void UpdateLayout(ListBox item, bool isfirst)
{
try
{
item.UpdateLayout();
if (isfirst)
item.ScrollIntoView(item.Items.First());
else
item.ScrollIntoView(item.Items.Last());
item.UpdateLayout();
}
catch (Exception ex)
{
//BugSenseHandler.Instance.SendExceptionAsync(ex);
//MessageBox.Show(ex.Message);
}
}