|
|
Here have some google foo[^]
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
hello guys... I wrote this code to scroll down to bottom automatically in a list whenever a new item is added to it. But it points to second last item not the last one. Here is the code
private void AutoScrollToBottom()
{
if (lstName.Items.Count > 0)
{
lstName.SelectedIndex = lstName.Items.Count - 1;
lstName.UpdateLayout();
lstName.ScrollIntoView(lstName.SelectedIndex);
}
}
Whats wrong with it .... thnx
|
|
|
|
|
I'm surprised that anything happens for you actually, as ScrollIntoView takes and object and not an index. This should work:
object objectToShow = lstName.Items[lstName.Items.Count - 1];
lstName.ScrollIntoView(objectToShow);
|
|
|
|
|
No, this did not work even though I appended lstName.UpdateLayout(); to your answer just b4 ScrollIntoView();.
|
|
|
|
|
Of course it doesn't work . And I bet I know why...
I'm guessing your code looks something like:
private void SomeMethod()
{
AddItem();
AutoScrollToBottom();
}
right?? .
This is one of the things that annoys me about WPF and always throws newbies (sorry if you are not, just this is well known to experienced WPF guys) for a loop.
When you have an item based control (ListBox, ListView, TreeView, etc), items are not really inserted into the control right away. They are inserted at some random point in the future. So what happens is exactly what you are seeing... your code says insert item #10, then it says "scroll to the last item" which still happens to be item #9. Then item #10 happens to be inserted. So you are scrolling to the second to last item because that was really the last item when your code executed.
What you need to do is subscribe to the ItemContainerGenerator.StatusChanged event and wait for the status to be ContainerGenerated on the item you want. Only then can you scroll it into view.
|
|
|
|
|
HI,
I am migrating from RadShceduler control from RadScheduleView for some performance problem. The requirement is to invoke the appointment create event in single click. In scheduler we have the TimeSloteItem which is not in RadScheduleView. I created a control template for timeslotitem and had the inputbindings to invoke the radscheduler appointment create event. I dont know how to achieve this in RadScheduleView. Plz Help... I used the following style..
<br />
<Style x:Key="AllDayTimeSlotStyle" TargetType="{x:Type telerik1:TimeSlotItem}"><br />
<br />
<Setter Property="Template"><br />
<Setter.Value><br />
<ControlTemplate TargetType="{x:Type telerik1:TimeSlotItem}"><br />
<Grid x:Name="LayoutRoot"><br />
<Grid.InputBindings><br />
<MouseBinding MouseAction="LeftClick" Command="commands:SchedulerCustomCommands.CreateAppointment" CommandParameter="{Binding RelativeSource={RelativeSource Mode=TemplatedParent}}" /><br />
</Grid.InputBindings><br />
.<br />
.<br />
.<br />
.<br />
.<br />
</ControlTemplate><br />
</Setter.Value><br />
</Setter><br />
</Style><br />
|
|
|
|
|
I find telerik support absolutely excellent for their controls, generally a sample app appears to solve most issues. Have you tried their forums.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi Jeyakumarbics1,
You don't need to create new template for TimeSlotItem. You need to attach function to MouseLeftButtonUp of RadScheduleView and in body of this function you need to create and execute CreateAppointment command.
private void ScheduleView_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
System.Windows.Input.RoutedUICommand createAppointment = RadScheduleViewCommands.CreateAppointment;
createAppointment.Execute(null, this.ScheduleView);
}
|
|
|
|
|
Hi,
I want to invoke the appointment create event in RadScheduleView with mouse single click instead of double click. By default it is invoked in mouse double click. How to get this done?
Plz Help? Urgent...
|
|
|
|
|
if (true == ((List<Author>)DG.ItemsSource).Any(el =>; el.Name == CurrentInput))
{
MessageBox.Show("Looking in column: " + ????? );
}
I don' t want to be always in the column Name, but in which is current. DG is the DataGrid. How?
|
|
|
|
|
I don't understand the question.
The columns are generally bound to some property in the data object for the row (the collection of these data items is the datagrid's ItemsSource). The datagrid's SelectedItem property will give you that object.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
1) You don't need "true =="
2) You don't need a semicolon after the => in your anonymous function
Anyway... You should be using FirstOrDefault() instead of Any(). That'll return the item that satisfied the condition, instead of just letting you know that such an item exists.
For example:
Person p = lstPeople.FirstOrDefault(a => a.Age > 18);
if (p != null)
{
}
|
|
|
|
|
I have a number of combo boxes on a datagrid, which are linked together using binding. So, if you select an item in the first combo then the user is presented with a list of values in the second based upon their selection in the first.
However, the problem I have is when the user changes their selected item in the first combo box, the list of values in the second is not updating to reflect the new selected item from the first.
My mark up in the combobox is
<ComboBox ItemSource="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type toolkit:DataGrid}}, Path=DataContext.Cars.SelectedCar}"
DisplayMemberPath="Car"
SelectedValuePath="Car"
SelectedItem="{Binding Path=SelectedCar, Mode=TwoWay, UpdateSourceTrigger}"
IsSynchronizedWithCurrentItem="True"/>
Can only please help??????????????????
|
|
|
|
|
I would guess that your path is wrong Path=DataContext.Cars.SelectedCar, SelectedCar doesn't sound like a list of objects.
If your path is not wrong, you should post a description of your source your binding against and the xaml for your datagrid with the comboboxes.
|
|
|
|
|
Hai!!!!!
How to update datas in silverlight Data grid. I used Following code But Getting Error in Linq query in service like .....
Argument Null Exception unhandle by user ...:
Value cannot be null.
Parameter name: entity
in this line : Dbcls.Bill_Applications.Attach(objBill,true);
This is my COde :
bill.xaml.cs
==============
public Bill()
{
InitializeComponent();
dgSilverlight.BeginningEdit +=new EventHandler<DataGridBeginningEditEventArgs>(dgSilverlight_BeginningEdit);
dgSilverlight.RowEditEnded +=new EventHandler<DataGridRowEditEndedEventArgs>(dgSilverlight_RowEditEnded);
}
void dgSilverlight_RowEditEnded(object sender, DataGridRowEditEndedEventArgs e)
{
MyBill_Application.ServiceReference1.Bill_Application objData = e.Row.DataContext as MyBill_Application.ServiceReference1.Bill_Application;
MyBill_Application.ServiceReference1.BILL_WCFServiceClient webservice = new MyBill_Application.ServiceReference1.BILL_WCFServiceClient();
webservice.Edit_User_Bill_InformationCompleted +=new EventHandler<Edit_User_Bill_InformationCompletedEventArgs>(webservice_Edit_User_Bill_InformationCompleted);
webservice.Edit_User_Bill_InformationAsync(objData);
}
protected void webservice_Edit_User_Bill_InformationCompleted(object sender, MyBill_Application.ServiceReference1.Edit_User_Bill_InformationCompletedEventArgs e)
{
bool result = Convert.ToBoolean(e.Result);
if (result)
{
}
}
void dgSilverlight_BeginningEdit(object sender, DataGridBeginningEditEventArgs e)
{
}
And Service Page
Service.srv.cs
=====================
[OperationContract]
public bool Edit_User_Bill_Information(Bill_Application objBill)
{
Dbcls.Log = new Vandermotten.Diagnostics.DebuggerWriter();
Dbcls.Bill_Applications.Attach(objBill,true); ***Error*** :doh:
Dbcls.SubmitChanges();
return true;
}
Can you please Help me out ?
Thanks and Regards,
Sanjay
|
|
|
|
|
From the error, it looks like you have no data.
Make sure you have data for the query that you are using.
Too much of heaven can bring you underground
Heaven can always turn around
Too much of heaven, our life is all hell bound
Heaven, the kill that makes no sound
|
|
|
|
|
I have code to add my tab items to the control and it works, however in the Microsoft Visual C# 2010 editor my tab shows up as a big gray box with no controls. When I run the program the tabs have there controls. Here is my TabItem
<br />
<br />
<TabItem xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Name="ThisMyTab" x:Class="GoCenter.MyTab" mc:Ignorable="d" d:DesignHeight="600" d:DesignWidth="800"><br />
<br />
<Grid><br />
My Controls here<br />
</Grid><br />
<br />
</TabItem >
David W Wright
|
|
|
|
|
david1313 wrote: I have code to add my tab items to the control and it works
So you are adding tabitems using code, yes?
I'm not sure how much of the construction/initialization code the editor runs in the classes we code, but if it's not showing up in the designer then you could always put a dummy TabItem in the XAML.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Yes, I'm adding tabs using code. How do you create a dummy TabItem?
David W Wright
|
|
|
|
|
Put that XAML in the TabControl if it's in XAML or add an item in the constructor perhaps?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I'm trying to make a tab with a close button (a la Firefox and pretty much everything else that uses tabs), and was trying to follow this tutorial:
How to add a Close button to a WPF TabItem[^]
Unfortnately, it doesn't seem to work. The problem appears to be that in the ClosableHeader class there is a button, defined in the xaml, with
Name="button_close" It's then referenced in the C# code for the ClosableTab class as follows:
CloseableHeader closableTabHeader = new CloseableHeader();
this.Header = closableTabHeader;
closableTabHeader.button_close.MouseEnter += new MouseEventHandler(button_close_MouseEnter);
closableTabHeader.button_close.MouseLeave += new MouseEventHandler(button_close_MouseLeave);
closableTabHeader.button_close.Click += new RoutedEventHandler(button_close_Click);
closableTabHeader.label_TabTitle.SizeChanged += new sizeChangedEventHandler(label_TabTitle_SizeChanged);
This generates compile-time errors for every line that contains the text
closableTabHeader.button_close with the message "'WGPM.Views.CloseableHeader' does not contain a definition for 'button_close' and no extension method 'button_close' accepting a first argument of type 'WGPM.Views.CloseableHeader' could be found (are you missing a using directive or an assembly reference?)" (WGPM.Views is the namespace I'm using).
What am I missing? Can I not just refer to a named control like that?
Thanks,
Juliean.
|
|
|
|
|
Sounds to me like either your XAML or code behind class is in the wrong namespace. They have to be in the same namespace to access stuff the way you are trying to.
|
|
|
|
|
Wouldn't that cause an error on the line where the CloseableHeader is created? If it was in a different namespace, I'd get a compile error at that time, wouldn't I? The CloseableHeader gets created correctly, and the assignment of it to the ClosableTab works, but the reference to button_close and label_TabTitle doesn't.
|
|
|
|
|
Not necessarily. The names such as "button_close" and "label_TabTitle" are actually defined in a compiler generated partial class thats not shown in Visual Studio. So the class itself might be in your scope, but the stuff inside it may not be.
Post more of your XAML and .cs class so we can take a look.
|
|
|
|