|
True, but it's easy to replicate the logic.
public static bool IsNullOrWhitespace(this string text)
{
if (string.IsNullOrEmpty(text))
return true;
return text.Trim() == string.Empty;
}
|
|
|
|
|
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.
|
|
|
|
|
Yes. You can just use the same converter. make sure that your converter always returns Visibility type instead null or string.
MVVM devotee
|
|
|
|
|
You could probably use a trigger. You can set visibility based on the true/false.
|
|
|
|
|
Hello,
i have created a listbox that uses databinding that contains many items
each item has two 2 textblock and one hyperlink button.
one textblock is named ID and is Collapsed.
when i press the hyperlink button i want to get the value stored in ID so i can pass it to a new Page that i open.
Is this possible, and how?
|
|
|
|
|
I don't know about others but I used :-
private void CheckBox_Unchecked(object sender, RoutedEventArgs e)
{
ComboBox cmb = (ComboBox)((sender as Control).Parent as Panel).Children.First(x => (x as Control != null) && (x as Control).Name == "cmbShipState");
cmb.Visibility = System.Windows.Visibility.Visible;
}
to find a sibling of a control on its click event.
I will appreciate if somebody can show me a better way to accomplish the same.
Note : The code is of different context but I think you can convert it for your scenario.
Thanks and Regards
Amar Chaudhary
HBCC-Tech
|
|
|
|
|
You might want to consider the command approach.
Pass in the id as the command parameter.
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.
|
|
|
|
|
My scenario is little different as I have to show/hide few controls in row detail template of data-grid - please suggest me something for that - an attached code example would be of great value.
Thanks and Regards
Amar Chaudhary
HBCC-Tech
|
|
|
|
|
Hi,
Its simple. Just get the data context of your hyperlink button or combobox, and get the business object property to get the actual value which you bound with textblock. Hope you can get my point.
MVVM devotee
|
|
|
|
|
Thanks for the answer, i'm new to silverlight so could you help me out to get the hiddenID value?
this is my listbox with the datatemplate
The listbox is loaded with many different items, the header=hyperlink does not have unique contents.
What i want is to pass the current HiddenID that correspons to the hyperlink
Ex:
hiddenID = 34
Hyperlink = "Recent events"
Content = "short description"
when i press "Recent events" and trigger the hyperlinkbutton event i want to be able to get the value from hiddenID
<ListBox x:Name="ListboxNews" ItemTemplate="{StaticResource NewsTemplate}" ItemsSource="{Binding _News}" Margin="8,38,8,8" Opacity="1" BorderThickness="0" Background="White" />
<DataTemplate x:Key="NewsTemplate">
<Grid Background="White" HorizontalAlignment="Left" Height="59" VerticalAlignment="Top" Width="265">
<HyperlinkButton x:Name="NewsHyperLink" Content="{Binding Header}" FontSize="18.667" FontWeight="Bold" FontFamily="/StartPage;component/Fonts/Fonts.zip#Calibri" Click="HyperlinkButton_Click" Background="{x:Null}" HorizontalAlignment="Left" VerticalAlignment="Top" d:LayoutOverrides="HorizontalAlignment, VerticalAlignment" Margin="10,0,0,0"/>
<TextBlock x:Name="Content" Text="{Binding Content}" TextWrapping="Wrap" Width="265" FontFamily="/StartPage;component/Fonts/Fonts.zip#Calibri" FontSize="16" Foreground="Black" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="12,23,0,0" />
<TextBlock x:Name="HiddenID" Text="{Binding NewsID}" Width="20" VerticalAlignment="Top" d:LayoutOverrides="VerticalAlignment" FontSize="16" HorizontalAlignment="Left" Margin="-2,0,0,0" />
</Grid>
</DataTemplate>
|
|
|
|
|
Hi,
Here is the Click Event handler which i said
private void Link1_Click(object sender, RoutedEventArgs e)
{
string id= ((sender as HyperlinkButton).DataContext as YourBusineesObject).HiddenID;
}
Let me know if this works.
MVVM devotee
|
|
|
|
|
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
|
|
|
|