RadGridView Items not updating with ItemsSource changed inside a TabItem - radgridview

I have an Grid inside a tabItem with is not focused in Windows_Load / Constructor, and if i feed the ItemsSource property, the Items property continues with 0 until i go to the tabItem.
I guess its something wrong with the renderization.
Here is the code:
IList<ProdutosProxy> lstProxy = ProdutosProxy.RetornarDadosProdutos(lstProdutos);
this.grdProdutosEservicos.ItemsSource = lstProxy;
this.grdProdutosEservicos.Items.Refresh();
The ItemsSource gets 1 item, but the Items continues with 0 until i focus the tabItem.
Already tried Rebind() and UpdateLayout().
Someone know something about that ?
Thanks

I solved the problem..
Just forced the update on Window_Loaded from tab/grid and goes back to original tab.
private void AtualizarGrid(String gridHeader)
{
for (var tabIndex = tabControl1.Items.Count - 1; tabIndex >= 0; tabIndex--)
{
if ((tabControl1.Items[tabIndex] as TabItem).Header.ToString() == gridHeader)
{
tabControl1.SelectedIndex = tabIndex;
tabControl1.UpdateLayout();
}
}
}

Related

Custom Cell Format ListView TornadoFx on delete item

I'm new to TornadoFx but am trying it out (also new to JavaFX by extension).
I have a listview defined as so:
private var colorList = mutableListOf<Color>
//other things in init block
colorpicker(mode = ColorPickerMode.MenuButton) {
valueProperty().onChange {
if (it != null) {
colorList.add(it)
}
}
}(Color.BLACK,Color.WHITE).observable()
listview(colorList) {
cellFormat {
text = it.toString()
style {
baseColor = it
}
}
contextmenu {
item("Delete").action {
if (selectedItem != null) {
colorList.remove(selectedItem)
}
}
}
}
//continue init block
Adding and taking away colors from the listview works just fine but the color inside the cell does not disapear if it is no longer occupied
Example of what is happening
The cellFormat function allows you to configure the list cell for each item in your list.
However, when there is no list item for a certain row, the callback is not run, so that you have no way of applying a style to an empty row using the cellFormat approach. One solution would be to implement your own ListCell and always clearing the style property of the cell, but I believe this might actually be fixed within the framework by always clearing the style property before a cell is reused. I just tried to make this change in the framework, and it fixes the issue with your code sample.
I will commit the change now, please try it out with tornadofx-1.7.17-SNAPSHOT :)

Show image when a ListBox contains no elements in Windows Phone 7

I want to show a list of items in a grid(in a listbox ofc) but if there are no items to show, I want to display in image instead of the listbox. The best way for this would be to create a Datateplate to determinate weather to show the listbox, or the image.
I would like to avoid setting the visibility of the image or the listbox in code.
Can this be done, and how? Or I have to use the method I wanted to avoid.
If you use MVVM, you could add property IsEmptyListVisibility and bind to it your image Visibility property to control when it displayed:
Visibility IsEmptyListVisibility
{
get
{
return (list.Count == 0) ? Visibility.Visible : Visibility.Collapsed;
}
}
Also, call NotifyPropertyChanged when сollection are changed to keep all in consistence
ObservableCollection<...> list
{
get { return _list; }
set
{
_list = value;
list.OnCollectionChanged += (s, e) =>
{
NotifyPropertyChanged("IsEmptyListVisibility");
}
}
}

how to dismiss the dropdown list of an autocompletebox in windows phone 7

is there anyway to programmatically dismiss the drop-down list of an autocompletebox? my use case is as follows.
MainPage.xaml passes a value to SearchPage.xaml (i.e. /SearchPage.xaml?query=someText).
in SearchPage.xaml.cs, i set,
autoCompleteBox.Text = NavigationContext.QueryString["query"].
at this point, the drop-down list of suggested matches shows up. i don't want this behavior when the page is just navigated to.
i also tried the following to dismiss the drop-down list but it didn't help.
autoCompleteBox.Text = NavigationContext.QueryString["query"];
autoCompleteBox.IsDropDownOpen = false;
the drop-down list seems to go away from the AutoCompleteBox when it loses focuses, but i don't see a property/field to set to make it lose focus.
any help is appreciated.
well, i tinkered a bit and came up with a kludge. in the constructor of SearchPage.xaml.cs i have the following code.
autoCompleteBox.TextFilter += DummyFilter;
autoCompleteBox.GotFocus += (s,args) => {
if(!isAutoCompleteBoxInit) {
autoCompleteBox.TextFilter -= DummyFilter;
autoCompleteBox.TextFilter += RealFilter;
}
}
DummyFilter looks like the following.
bool DummyFilter(string search, string value) { return false; }
RealFilter looks like the following.
bool RealFilter(string search, string value) {
if(null != value) return value.ToLower().StartsWith(search.ToLower());
}
in my OnNavigatedTo method, is where i set, autoCompleteBox.Text = NavigationContext.QueryString["query"]. so when i do this now, the DummyFilter will always return false, so the drop-down list goes away. when the user focuses in on the AutoCompleteBox, i check if the correct Filter was already attached to the TextFilter property, if not, then i do a switch.
hope this helps some of you.
Is there any other focusable control on the page? Just set the focus somewhere else, and your problem should be solved.
When you have changed the text of the AutoCompleteBox the dropdown will open. Only when the user has changed the text and there is a match then the dropdown will close.
Just change userInitiated to true and when there is a match the dropdown will close.
private void UpdateTextCompletion(bool userInitiated)
{
userInitiated = true; ...

Adding scrollbar to Telerik GridViewDataControl for expandable grid item

I have a Telerik:RadGridView that has items in it, some of which are expandable. The decision to make the row expandable is done in the RowLoaded event by setting the IsExpandable flag based on the type of object in the row. This works great.
To handle the row expansion, I have a method to handle the DataLoading event. It looks like this:
void AssignedNumbersGrid_DataLoading(object sender, GridViewDataLoadingEventArgs e)
{
GridViewDataControl dataControl = (GridViewDataControl)sender;
if (dataControl.ParentRow != null)
{
dataControl.ShowGroupPanel = false;
dataControl.AutoGenerateColumns = false;
dataControl.CanUserFreezeColumns = false;
dataControl.IsReadOnly = true;
dataControl.SelectionMode = System.Windows.Controls.SelectionMode.Extended;
dataControl.IsFilteringAllowed = false;
dataControl.ShowInsertRow = false;
dataControl.RowIndicatorVisibility = Visibility.Collapsed;
dataControl.ChildTableDefinitions.Clear();
dataControl.Margin = new Thickness(0, 0, 0, 0);
dataControl.EnableRowVirtualization = true;
dataControl.MaxHeight = 100;
ScrollViewer.SetVerticalScrollBarVisibility(dataControl, ScrollBarVisibility.Auto);
dataControl.Columns.Add(BuildSelectColumn());
dataControl.Columns.Add(BuildNewColumn("Range Number", "DisplayAssociatedInfo"));
dataControl.Columns.Add(BuildTypeColumn());
dataControl.Columns.Add(BuildRemarkColumn());
dataControl.Columns.Add(BuildNewColumn("Status", "DisplayStatus"));
}
}
I added the code to set the max height and the attached scroll viewer but the scroll bar does not show up. the dataControl object is of type GridViewDataControl, which is not the same as a RadGridView. Does anyone know how I can get a scroll bar to show on the expanded grid? The reason I need this is that the expanded grid may contain several hundred items and it takes several seconds to build the grid if it's large. I am thinking that with row virtualization and a scroll bar, it will be much faster.
Have you tried this:
<telerik:RadGrid ..>
.....
<ClientSettings EnableRowHoverStyle="True">
<Scrolling AllowScroll="True" EnableVirtualScrollPaging="True" SaveScrollPosition="True">
</Scrolling>
</ClientSettings>
</telerik:RadGrid>
I solved the problem by using a row details feature. The row details has another grid that contains the child items. The performance for this option is very fast.

Why won't my C++/CLI tooltip appear?

I have some validation code which should display the max / min of a control when a bad value is entered.
In my constructor I do this:
m_wndToolTip = gcnew ToolTip(this->components);
m_wndToolTip->AutoPopDelay = 5000;
m_wndToolTip->InitialDelay = 10;
m_wndToolTip->ReshowDelay = 250;
m_wndToolTip->ShowAlways = true;// Force the ToolTip text to be displayed whether or not the form is active.
This is my validation reflection code:
void MyGUI::IndicateValidationResult(Windows::Forms::Control^ control, bool isValid, String^ invalidReason)
{
// If the validation failed, make the background red. If not, turn it white.
if( isValid )
{
control->BackColor = Drawing::Color::White;
m_wndToolTip->Hide(control);
}
else
{
control->BackColor = Drawing::Color::LightCoral;
m_wndToolTip->Show(invalidReason, control);
}
}
...which is called from varous ValueChanged methods in my text boxes. I've tried using show and also a combination of SetToolTip and active = true and nothing seems to work.
I've seen another question asking about tooltips and have tried setting a nearby label in the call to show but that doesn't fix it either. The tooltip is a member variable in my System::Windows::Forms::Form derived form to stop it going out of scope.
Am I missing something obvious?
Your code worked fine when I tried it, there's no obvious mistake that I can see. I called it like this, using a Validating event of a text box:
bool ok;
System::Void textBox1_Validating(System::Object^ sender, System::ComponentModel::CancelEventArgs^ e) {
e->Cancel = !ok;
IndicateValidationResult(textBox1, ok, "invalid");
ok = !ok;
}
Beware that ToolTip can be cranky. The native Windows component has a "feature" that prevents a tooltip from showing again when it timed out before. The ErrorProvider component is a better mouse trap to get this done.

Resources