|
Hi!
Yes, i got it working, many thanks !!!
|
|
|
|
|
Great. Enjoy
MVVM devotee
|
|
|
|
|
Yep, i've done a fair amount of goggling with no success. Did anyone ever figure out a solution to this problem?
The one solution that i tried was connecting to the textbox's lostfocus event, and then setting e.handled = true. Yep it didn't work xD
|
|
|
|
|
You might want to try something like editing a text box's selected text style to include a border or a rectangle that displays on top of the selected text once some text is selected and focus is lost.
Does this[^] custom control help by any chance?
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
My latest tip/trick
Visit the Hindi forum here.
|
|
|
|
|
I figured it out. Was pretty easy lol.
Just added this to my main window to consume the WM_KILLFOCUS message, and by doing so i disabled the textbox from ever getting notified that focus for the app has been lost
<br />
const int WM_KILLFOCUS = 8;<br />
<br />
protected override void OnSourceInitialized(EventArgs e)<br />
{<br />
base.OnSourceInitialized(e);<br />
HwndSource source = PresentationSource.FromVisual(this) as HwndSource;<br />
source.AddHook(WndProc);<br />
}<br />
<br />
IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)<br />
{<br />
if (msg == WM_KILLFOCUS)<br />
handled = true;<br />
<br />
return IntPtr.Zero;<br />
}<br />
Additionally, i also subscribed to the TextBox's LostFocus event in order to prevent the textbox from losing focus to another control, which would also result in the TextBox loosing the selection highlighting.
<br />
private void textBoxReadingMaterial_LostFocus(object sender, RoutedEventArgs e)<br />
{<br />
e.Handled = true;
}<br />
modified on Sunday, October 24, 2010 1:54 AM
|
|
|
|
|
Thanks for posting your solution here.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
My latest tip/trick
Visit the Hindi forum here.
|
|
|
|
|
This is a pretty dangerous thing to do - focus management in WPF is nothing like focus control in Winforms because it has to manage focus in both the logical and visual tree.
|
|
|
|
|
Ok, i was able to replace half of the solution with wpf-acceptable code, i.e. for a separate stackpanel, which contained controls which i didn't want to steal focus from my textbox, i simply set that stackpanel to have this property: FocusManager.IsFocusScope="true", and what i understand this did was create a separate focus-tree/scope/thing so those controls would not be able to affect my textboxes focus. (source: http://wpfhacks.blogspot.com/2009/06/correct-way-keep-selection-in-textbox.html)
But so far i do not see an alternative to the following code, which prevents the textbox from being notified that the window lost focus:
<br />
#region WndProc in order to prevent the textbox from loosing focus when the window losses focus<br />
<br />
const int WM_KILLFOCUS = 8;<br />
<br />
protected override void OnSourceInitialized(EventArgs e)<br />
{<br />
base.OnSourceInitialized(e);<br />
HwndSource source = PresentationSource.FromVisual(this) as HwndSource;<br />
source.AddHook(WndProc);<br />
}<br />
<br />
IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)<br />
{<br />
if (msg == WM_KILLFOCUS)<br />
handled = true;<br />
<br />
return IntPtr.Zero;<br />
}<br />
<br />
#endregion<br />
modified on Tuesday, October 26, 2010 5:38 PM
|
|
|
|
|
Good Day
I've a trouble with TreeView Multibinding in WPF.
I have some classes and TreeView Control
Classes:
public class Company{
public string Title {get; set;}
public string Country {get; set;}
public List<Company> ChildCompanies {get; set;}
public Company ParentCompany {get; set;}
public List<Project> Projects {get; set;}
}
public class Project{
public string Title {get; set;}
public int Price {get; set;}
public Company ParentCompany {get; set;}
}
And Something like this:
<Window>
...
...
<Window.Resources>
<HierarhicalDataTemplate DataType="{x:Type local:Company}">
<HierarhicalDataTemplate.ItemsSource>
<MultiBinding Converter=""> !!!!!!!!!!!!!!!!!!!!!!!!!
<Binding Path="ChildCompanies"/>
<Binding Path="Projects"/>
</MultiBinding>
</HierarhicalDataTemplate.ItemsSource>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Title}"/>
</StackPanel>
</HierarhicalDataTemplate>
</Window.Resources>
<TreeView Name="CorporationTree"></TreeView>
</Window>
I need to see in treeview control the elements of two classes like in Windows explorer, where:
Companies it's something like folders with subfolders possibility
and Projects it's something like Files in current Folders.
I don't understand how to implement this multibinding and i don't understand what is converter and how it works.
Please help to solve this problem.
|
|
|
|
|
hi all i'm new in silverlight ,mvvm,ris services
all what i need a simple example to fill datagrid with MVVM pattern and using ria services
here is my steps and may be i miss any step
note :i just have a one page include datagrid i want to show data on it from employee table in adveture work databas
1-add my entity framework
2-add ria services domain services1
3-in the silverligh project i make a folder name in viewmodel
4-and add a c# class called ViewModelBase
here is the implementation for this class
public event PropertyChangedEventHandler PropertyChanged;
public void RaisePropertyChanged(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
5-in the construcor of this above class i call the DomainService1 "RIA service "
6-in the same class i make a property to get the all emplyee to show it in the gridview
private ObservableCollection<employee1> _employees;
public ObservableCollection<employee1> Employees
{
get
{
return _employees;
}
set
{
_employees = value;
RaisePropertyChanged("Employees");
}
}
thats all what i miss ???????????????????
the datagrid dont display any data
please answerd me thanks alot for any help
Kimo Code
|
|
|
|
|
Did addiding DX11 to .NET 4.0 break the goodness we enjoyed in 3.5 between SL and WPF?
Don't reply to this, just vot using the rate this, button at bottom, unless you want to voice your own opinion.
@ProtoBytes
|
|
|
|
|
Microsoft claimes that SketFlow is used to give the Develoer a jump start by allowing the designers rendenditon to be ported into a new project and generate a new solution based on the exact specifications of the protottype. I would like to write an article seriexe on this, I have been lkeeping my eye oen for a while now, bot have not found any information that walks you throught the end-toend process.
@ProtoBytes
"'I'm in alpha testing acceptance of IE9, so far so good. Like it better then chrome!', watched ScottGu's Win7 Phone on channel9 in HTML5, you could see the detail in his 5 PM shadow very nice work MS!
|
|
|
|
|
This was easy to do in 3.5 and 3.5-SP2. and also easy to accomplish using GDI. However I need GPU acceleration on the Client of a Sliver Light Application I'm writing and need to generate a Writable Bit Map Image on the fly using GPU hard ware acceleration. I have tried this in both WPF and Silverlight, and found the documentation code doesn't even work that MSDN has on display. ScottGu made a small post about it, but I was not able to find a reference to the APIs he mentioned.
This is a heave weight scientific mathematical graphical animation sequence, much like creating a Mandelbrot space auto explorer, however it has real scientific and mathematical value as a tool, not eye-candy. It also needs to use the Share language to perform some Hardware manipulations of the images. The images are based completely off of dwrights work on complex color maps: Visualizing Complex Functions I am in the process of porting the Meta Numeric library to CUDA, and also trying to port dwrights code for this demo to SIlverlight and WPF as my project uses his work, and leverages some other interesting features, full explanation here:
ProtoBytes@msdn.microsoft.com - Monads Blog Entries
@ProtoBytes
|
|
|
|
|
I have using the designer to create XAML images from other images using the Image Auto Trace tool. This works find, but when I try to apply an effect, it locks up. I'm running a AMD 965 8 GB. Memory DDR3 1333 CL9 50ns. w/ Nvidia GeForce 460 GPU. Last time I ran Studio, I recall it was using the GUP, now I get 100% CPU usage when I attempt to do the same type of rendering on my Vector images. They can be quite large, but don't max out my 8 GB. of memory, and the Video chairs 4Gb. of the memory, so there is plenty of video memory.
Anyone know how to get the Expression suite o use more of the GPU and less of the Processor, and yes I'm OC'ing at 3.8 GHz. (Completely stable at 57 degrees C)
@ProtoBytes
|
|
|
|
|
Where is the best place get get information on how to take a user control; like one downloaded from the Sliverlight Gallery, and add it to an exsisting project, or better yet create a completly new user control libabrary of all controls with a user control test suite project as part of the solution to bother verify the code works and the page load doens't hang, UI thread lock etc.
I recently downloaded the example code for the 'Binary Clock' on the Silver Light Gallery and modified teh animation so the dots changed colr based on the binary bit they were in. The control works just fin in blend 4 and runs smoothly, however when I load my page I get the blue sliverlight spinning gizmo and no page load.
So I attempted to just add the usercromtrol directly to the project instead of suing it as an asset from another project in the solution. no go!
Then I create a user control libabary, and got distracted, when I found MEF 2 Preview and patched it by lazy signing each class at build time, to demonstate in an article.
@ProtoBytes
|
|
|
|
|
Hi all,
I want to make a master detail screen. Get master and detail data from WCF service.
Dataform should get validation, error message etc.. from the class. but I can't get metadata from the WCF.
I try to Domain Service Class in WCF but I can't create context with Linq.
How can i use dataform with WCF. please help
S.A.A
|
|
|
|
|
|
Hello im new to Silverlight and i'm having a problem with consuming a WCF service. i have created a Currentname.cs that i use for databinding.
And news.cs where i store the data
The problem is when i call the service the it doesn't trigger the "event"
and populate the propery
Could anyone help?
<br />
<br />
private ObservableCollection<News> _PrivateNews;<br />
public ObservableCollection<News> _News <br />
{<br />
get<br />
{<br />
if (_PrivateNews.Count == 0)<br />
{<br />
getData();<br />
}<br />
return _PrivateNews;<br />
}<br />
set<br />
{<br />
_PrivateNews = value;<br />
if (PropertyChanged != null)<br />
PropertyChanged(this, new PropertyChangedEventArgs("News"));<br />
}<br />
}<br />
<br />
public void getData()<br />
{<br />
ServiceReference1.Service1Client newservice = new ServiceReference1.Service1Client();<br />
newservice.GetNewsCompleted += new EventHandler<ServiceReference1.GetNewsCompletedEventArgs>(newservice_GetNewsCompleted);<br />
newservice.GetNewsAsync();<br />
}<br />
<br />
void newservice_GetNewsCompleted(object sender, ServiceReference1.GetNewsCompletedEventArgs e)<br />
{<br />
<br />
ObservableCollection<News> myNews = new ObservableCollection<News>();<br />
foreach (ServiceReference1.P_GetSomeNewsResult x in e.Result)<br />
{<br />
News n = new News();<br />
n.Header = x.NewsHeader;<br />
n.Content = x.News;<br />
myNews.Add(n);<br />
}<br />
_News = myNews;<br />
}<br />
modified on Friday, October 22, 2010 8:56 AM
|
|
|
|
|
Looks like you are firing a property change for "News", but your property is called "_News".
|
|
|
|
|
Thanks, the binding works great now
|
|
|
|
|
I should source code for example to new project me it's about Assign Datagrid Value From Child Web Page To A Textbox In Parent Webform by silverlight. I don't know,How to write source code?..
|
|
|
|
|
I am having an issue with editing my data in a row details template. Has anyone experienced this issue? Here is some of the XAML:
<DataGrid
ItemsSource="{Binding AllInspections}"
AutoGenerateColumns="False"
Grid.Row="4"
Margin="5,0,0,0"
SelectedItem="{Binding SelectedInspection}">
<DataGrid.RowDetailsTemplate>
<DataTemplate>
<TextBox
Text="{Binding Notes, Mode=TwoWay}" />
</DataTemplate>
</DataGrid.RowDetailsTemplate>
Save code is simple datacontext.SaveChanges()
The Binding Notes is displaying the information, but I can't get it to save and update. Nor anything I put into Row Details. When I include the field in the datagrid as a text box row it works fine. Thoughts?
P.S. After testing I see that the associated item (SelectedInspection) is not being updated nor is the observablecollection AllInspections. So putting the "Save" and datacontext updating aside, it looks like I cannot update the observablecollection from my rowdetails.
Cheers, --EA
P.P.S After messing around with this enough I ended up changing the binding of the textbox to:
Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGrid}},Path=SelectedItem.Notes}" />
So I suspect the issue has something to do with the "SelectedItem" of the datagrid not being available to the RowDetailsTemplate. I am not sure why this would result in being able to display the data using {Binding Notes} and not edit it, but c'est la vie. If anyone has insight about this, I would appreciate it.
modified on Friday, October 22, 2010 5:06 PM
|
|
|
|
|
I am new to WPF, so bear with him.
I want to have a GridView with 2 columns, displaying custom controls, which has X amount of rows.
The data i am given is in a list format, which i then need to display as follows: i want to insert item 1 in column 1 and item 2 in column 2 for row 1. And then item 3 in column 1 and item 4 in column 2 for row 2, and so on - (Think of it a bit like a photo gallery)
The custom control will display the details for each item, which i have already created.
The problem i have is, how do i bind the data to the GridView.
My initial idea was to split the data into rows, i.e.: have several lists, that contain 2 items. This allows me to know that item 1 is for column 1 and item 2 is for column 2, i can then work my way through all the lists and end up with all the rows populated with the custom controls.
However, i cant work out how to programmtically add a new row, which should have a control in each column.
Am i going about it the right way? Or barking up the wrong tree...
Hopefully i've made sense.
Cheers.
Regards,
Gareth.
(FKA gareth111)
|
|
|
|
|
I've changed my idea to have to have 2 stack panels, as this seems more fitting.
Regards,
Gareth.
(FKA gareth111)
|
|
|
|
|
Solved.
Regards,
Gareth.
(FKA gareth111)
|
|
|
|
|