Wpf Extended toolkit BusyIndicator não aparece durante a operação
Eu tenho uma operação bastante longa que ocorre em um trabalhador em segundo plano. Eu tenho o indicador de ocupado definido como true antes da operação e false quando a operação termina, mas o indicador nunca é exibido. Isso aparece em outras partes do meu programa, mas não neste. aqui está o código:
<xctk:BusyIndicator DockPanel.Dock="Top" Name="ItemSearchBusyIndicator" >
<Grid Height="35" Name="grid1" Width="445" DockPanel.Dock="Top">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="382*" />
<ColumnDefinition Width="39*" />
</Grid.ColumnDefinitions>
<RadioButton Content="Direct Entry" Height="16" HorizontalAlignment="Left" Margin="212,10,0,0" Name="RdoDirectEntry" VerticalAlignment="Top" IsChecked="False" Checked="RdoDirectEntry_Checked" FontSize="14" />
<RadioButton Content="Item Search" Height="16" HorizontalAlignment="Left" Margin="0,10,0,0" Name="RdoItemSearch" VerticalAlignment="Top" Checked="RdoItemSearch_Checked" FontSize="14" />
<RadioButton Content="Route Search" Height="16" HorizontalAlignment="Left" Margin="102,10,0,0" Name="RdoRouteSearch" VerticalAlignment="Top" Checked="RdoRouteSearch_Checked" FontSize="14" />
<RadioButton Content="File System Search" Height="16" HorizontalAlignment="Left" Margin="310,11,0,0" Name="RdoFileSystem" VerticalAlignment="Top" FontSize="14" Grid.ColumnSpan="2" Checked="RdoFileSystem_Checked" />
</Grid>
</xctk:BusyIndicator>
private void CboItemId_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
BackgroundWorker _backgroundWorker = new BackgroundWorker();
_backgroundWorker.DoWork += new DoWorkEventHandler(backgroundWorker_DoWork);
_backgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(_backgroundWorker_RunWorkerCompleted);
ItemSearchBusyIndicator.IsBusy = true;
// Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
if (RdoItemSearch.IsChecked == false) return;
backgroundWorker_DoWork(null, null);
// Mouse.OverrideCursor = System.Windows.Input.Cursors.Arrow;
ItemSearchBusyIndicator.IsBusy = false;
}
public void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
{
if (CboItemId.SelectedValue == null) return;
if (CboItemId.SelectedValue.ToString() != string.Empty)
LoadItemData(CboItemId.SelectedValue.ToString());
}
public void LoadItemData(string itemId)
{
Axapta ax = new Axapta();
files.Clear();
try
{
ax.Logon(Settings.Default.Server, null, Settings.Default.Test, null);
AxaptaContainer path = (AxaptaContainer)ax.CallStaticClassMethod(Settings.Default.ClassName, Settings.Default.ItemData, itemId);
for (int i = 1; i <= path.Count; i++)
{
AxaptaContainer somestring = (AxaptaContainer)path.get_Item(i);
for (int j = 1; j <= somestring.Count; j += 2)
{
string extension = Path.GetExtension(somestring.get_Item(j + 1).ToString().ToLower());
if (extension == ".jpg"
|| extension == ".jpeg"
|| extension == ".gif"
|| extension == ".png"
|| extension == ".bmp"
|| extension == ".pdf")
/* key=path - value=description */
files.Add(somestring.get_Item(j + 1).ToString(), somestring.get_Item(j).ToString());
}
}
if (path.Count == 0)
{
MessageBox.Show("No Documents Found");
}
_canvas.Children.Clear();
LoadPictures();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
ax.Logoff();
}
}
A substituição do mouse em CboItemId_SelectionChanged funciona bem quando eu o uso, mas prefiro usar o indicador de ocupado. o indicador aparece APÓS a operação, se eu apenas configurá-lo como verdadeiro e nunca configurá-lo como falso.