7,657
社区成员
发帖
与我相关
我的任务
分享
public ResponsableCommandBar()
{
this.DefaultStyleKey = typeof(ResponsableCommandBar);
this.SizeChanged += (sender, e) =>
{
if (e.NewSize.Width == e.PreviousSize.Width)
{
}
else
{
var addedWidth = e.NewSize.Width - (PrimaryCommands.Count * ButtonWidth + MoreWidth);
int buttonCount;
if (addedWidth > 0)
{
buttonCount = (int)(addedWidth / ButtonWidth);
for (int i = 0; i < buttonCount && SecondaryCommands.Count > 0; i++)
{
var command = SecondaryCommands[0];
var button = command as Button;
System.Diagnostics.Debug.WriteLine(button.IsEnabled);
SecondaryCommands.RemoveAt(0);
System.Diagnostics.Debug.WriteLine(button.IsEnabled);
PrimaryCommands.Add(command);
System.Diagnostics.Debug.WriteLine(button.IsEnabled);
}
System.Diagnostics.Debug.WriteLine("");
}
else if (addedWidth < 0)
{
buttonCount = (int)(-addedWidth / ButtonWidth);
for (int i = 0; i < buttonCount && PrimaryCommands.Count > 0; i++)
{
var index = PrimaryCommands.Count - 1;
var command = PrimaryCommands[index];
var button = command as Button;
System.Diagnostics.Debug.WriteLine(button.IsEnabled);
PrimaryCommands.RemoveAt(index);
System.Diagnostics.Debug.WriteLine(button.IsEnabled);
SecondaryCommands.Insert(0, command);
System.Diagnostics.Debug.WriteLine(button.IsEnabled);
}
System.Diagnostics.Debug.WriteLine("");
}
}
};
};
const double ButtonWidth = 68;
const double MoreWidth = 48;