|
Hi!
Imports System.Windows.Browser
HtmlPage.Window.Navigate(New Uri("http://zzz-server/zzz/Employees.aspx"), "_blank", "")
|
|
|
|
|
Do some research into navigation (assuming you do not just want an HTML page) here are the results of a search [^]in this forum, plenty of rich pickings in there.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
You can use Microsoft Prism[^] where your main screen is divided into regions.
Views (xamls) can then be removed and added to these regions.
Removing and adding views gives an effect of navigating across the application.
|
|
|
|
|
Hi friends,
I want basic idea how I can achieved sword effect. The one we see in fruit Ninja with which it cut fruits,
WANTED wasim khan(Killed 50 Innocent Buggs, Distroyed 200 Exception, make 5 Project Hostage) any Compnay Hire him will pay 30,000. Best place where u can get him is Sorcim Technologies Murre Road RWP
|
|
|
|
|
I don't have a clue, but the subject is funny.
Watched code never compiles.
|
|
|
|
|
WANTED wasim khan(Killed 50 Innocent Buggs, Distroyed 200 Exception, make 5 Project Hostage) any Compnay Hire him will pay 30,000. Best place where u can get him is Sorcim Technologies Murre Road RWP
|
|
|
|
|
http://www.fruitninja.com/[^] might be what he was talking about
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Ok, I finally got my treeview with hyperlinks working. Thanks SledgeHammer!
I now have the following
<Window.Resources>
<Style x:Key ="linkStyle"
TargetType="{x:Type Hyperlink}" >
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="TextBlock.TextDecorations" Value="Underline"/>
<Setter Property="Foreground" Value="RoyalBlue" />
</Trigger>
<Trigger Property="IsMouseOver" Value="False">
<Setter Property="TextBlock.TextDecorations" Value="{x:Null}"/>
<Setter Property="Foreground" Value="RoyalBlue" />
</Trigger>
</Style.Triggers>
</Style>
<HierarchicalDataTemplate DataType="{x:Type models:NodeModel}"
ItemsSource="{Binding Path=Children}">
<StackPanel Orientation="Horizontal"
Margin="2">
<TextBlock>
<Hyperlink NavigateUri="{Binding Caption}"
Foreground="#0C2DAA"
Style="{StaticResource linkStyle}"
CommandParameter="{Binding}"
Command="{Binding Path=DataContext.SelectedLinkCommand,
RelativeSource={RelativeSource FindAncestor,
AncestorType={ x:Type views:MainWindowView}}}">
<InlineUIContainer>
<TextBlock Text="{Binding Caption}" />
</InlineUIContainer>
</Hyperlink>
</TextBlock>
</StackPanel>
</HierarchicalDataTemplate>
</Window.Resources>
<Grid>
<controls:TreeViewEx ItemsSource="{Binding TreeData}"
SelectedItemEx="{Binding SelectedTreeItem, Mode=TwoWay}"
Grid.Row="0"
Grid.Column="0">
<TreeView.Resources>
<!--Make the selected item's background transparent-->
<SolidColorBrush Color="Transparent" x:Key="{x:Static SystemColors.HighlightBrushKey}"/>
</TreeView.Resources>
<TreeView.ItemContainerStyle>
<Style TargetType="{x:Type TreeViewItem}">
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />
</Style>
</TreeView.ItemContainerStyle>
</controls:TreeViewEx>
</Grid>
I'd really like to have all the treeview styling done in one place, but I'm not sure how. I would like to move
<TreeView.Resources>
<!--Make the selected item's background transparent-->
<SolidColorBrush Color="Transparent" x:Key="{x:Static SystemColors.HighlightBrushKey}"/>
</TreeView.Resources>
<TreeView.ItemContainerStyle>
<Style TargetType="{x:Type TreeViewItem}">
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />
</Style>
</TreeView.ItemContainerStyle>
out of the treeview up to the Window.Resources section.
If it's not broken, fix it until it is
|
|
|
|
|
|
Hello,
I have a problem I do a lot of research on the net but no solution.
I have a web service deployed in a server and an application in silverlight 4 on my machine, I call the web service from my application but I get an exception here is the exception:
CommunicationException was unhandled by user code: The remote server returned an error: NotFound
Thank you in advance for your help.
|
|
|
|
|
Have you checked to see that your web service is directly accessible? To do this, open it up in IE using the address you are using in your Silverlight application.
|
|
|
|
|
yes , the web service is directly accessible from IE
|
|
|
|
|
If you are still having this issue, I would recommend trying the techniques talked about here[^].
|
|
|
|
|
It does irritate me when some dipstik downvotes a helpful response - overbalanced!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I can only assume it's because I didn't wave the magic code wand.
|
|
|
|
|
Message size limit could also be the reason for this kind of error, try to increase the MessageSize in your service.
|
|
|
|
|
|
I'v been struggling with this all morning. Cold use some help...
I have created a HierarchicalDataTemplate used in a treeview. I have a class that overrides the basic treeview, called TreeViewEx, that I got from someone here at CP. (Can't remember who - sorry).
At any rate, here's the template:
<HierarchicalDataTemplate DataType="{x:Type models:TreeItemModel}"
ItemsSource="{Binding Path=Children}">
<StackPanel Orientation="Horizontal"
Margin="2">
<TextBlock Margin="0,0,5,0">
<Hyperlink NavigateUri="{Binding Caption}"
Foreground="#0C2DAA"
Style="{StaticResource linkStyle}"
Command="{Binding Path=DataContext.SelectedLinkCommand,
RelativeSource={RelativeSource FindAncestor,
AncestorType={ x:Type views:MainWindowView}}}">
<InlineUIContainer>
<TextBlock Text="{Binding Caption}" />
</InlineUIContainer>
</Hyperlink>
</TextBlock>
</StackPanel>
</HierarchicalDataTemplate>
and here's the treeview usage:
<controls:TreeViewEx ItemsSource="{Binding TreeItems}"/>
and finally the code behind:
private TreeItemModel _SelectedTreeLink;
public TreeItemModel SelectedTreeLink
{
get { return _SelectedTreeLink; }
set
{
if (_SelectedTreeLink != value)
{
_SelectedTreeLink = value;
RaisePropertyChanged("SelectedTreeLink");
}
}
}
private ICommand _SelectedLinkCommand;
public ICommand SelectedLinkCommand
{
get
{
if (_SelectedLinkCommand == null)
_SelectedLinkCommand = new RelayCommand(SelectedLinkExecuted, SelectedLinkCanExecute);
return _SelectedLinkCommand;
}
}
private bool SelectedLinkCanExecute()
{
return true;
}
private void SelectedLinkExecuted()
{
var item = SelectedTreeLink;
}
The tree loads with data fine, and they tree nodes are hyperlinks. The command works. However, when I break in the SelectedLinkExecuted method, SelectedTreeLink = null.
How can I get a reference to the data model behind the link?
Thanks
If it's not broken, fix it until it is
|
|
|
|
|
You could try using the CommandParameter property of the Hyperlink. Just set it to "{Binding}" , and the RoutedEventArgs class should contain a reference to the current object in its Parameter property.
You'll have to use the RelayCommand a bit differently, though, to get that RoutedEventArgs object into your handler.
|
|
|
|
|
Ok, I think I understand. Do you have an example?
If it's not broken, fix it until it is
|
|
|
|
|
I'm not that familiar with whichever RelayCommand implementation you're using (I've developed my own ways of organizing command-bindings), but the XAML is just:
CommandParameter="{Binding}"
But if it was a normal RoutedEventHandler, it would look something like:
private void ExecuteMyCommand(object sender, ExecutedRoutedEventArgs e)
{
MyModelClass modelItem = (MyModelClass)(e.Parameter);
}
|
|
|
|
|
I think you got that from me lol. From the code you posted, it seems like you didn't bind the treeview's selected item to the VM.
|
|
|
|
|
Actually I had this earlier...
<controls:TreeViewEx ItemsSource="{Binding TreeItems}"
SelectedItemEx="{Binding SelectedTreeLink}"/>
but it didn't change anything so I removed it.
and here's the TreeViewEx. Is this your code?
public class TreeViewEx : TreeView
{
public static readonly DependencyProperty SelectedItemExProperty = DependencyProperty.Register("SelectedItemEx", typeof(object),
typeof(TreeViewEx), new FrameworkPropertyMetadata(null, new PropertyChangedCallback(OnSelectedItemExChanged)));
public TreeViewEx()
: base()
{
SelectedItemChanged += new RoutedPropertyChangedEventHandler<object>(TreeViewEx_SelectedItemChanged);
}
public object SelectedItemEx
{
get { return (object)GetValue(SelectedItemExProperty); }
set { SetValue(SelectedItemExProperty, value); }
}
public bool SelectItem(object item)
{
if ((SelectedItem != null) && (SelectedItem.Equals(item)))
return true;
if (!ExpandAndSelectItem(this, item))
{
UpdateLayout();
return ExpandAndSelectItem(this, item);
}
return true;
}
private static void OnSelectedItemExChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
TreeViewEx treeView = d as TreeViewEx;
if ((object)treeView != null)
treeView.SelectItem(e.NewValue);
}
private void TreeViewEx_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
{
SetValue(SelectedItemExProperty, e.NewValue);
}
private bool ExpandAndSelectItem(ItemsControl parentContainer, object itemToSelect)
{
TreeViewItem tvi = parentContainer.ItemContainerGenerator.ContainerFromItem(itemToSelect) as TreeViewItem;
if ((object)tvi != null)
{
tvi.IsSelected = true;
tvi.BringIntoView();
tvi.Focus();
return true;
}
for (int nIndex = 0; nIndex < parentContainer.Items.Count; nIndex++)
{
TreeViewItem currentContainer = parentContainer.ItemContainerGenerator.ContainerFromIndex(nIndex) as TreeViewItem;
if (((object)currentContainer != null) && (currentContainer.Items.Count > 0))
{
bool bIsExpanded = currentContainer.IsExpanded;
if (currentContainer.ItemContainerGenerator.Status != GeneratorStatus.ContainersGenerated)
{
EventHandler handler = null;
handler = new EventHandler(delegate
{
if (currentContainer.ItemContainerGenerator.Status == GeneratorStatus.ContainersGenerated)
{
if (ExpandAndSelectItem(currentContainer, itemToSelect) == false)
currentContainer.IsExpanded = false;
currentContainer.ItemContainerGenerator.StatusChanged -= handler;
}
});
currentContainer.ItemContainerGenerator.StatusChanged += handler;
if (currentContainer.IsExpanded == false)
currentContainer.IsExpanded = true;
}
else
{
if (ExpandAndSelectItem(currentContainer, itemToSelect) == false)
currentContainer.IsExpanded = bIsExpanded;
else
return true;
}
}
}
return false;
}
}
If it's not broken, fix it until it is
|
|
|
|
|
You need to make SelectedItemEx mode=TwoWay.
|
|
|
|
|
Still no joy.
Tomorrow I'm going to abstract this out into a sandbox app. That'll allow me to work without all the other app code I have. Plus if I need to I can post the sample app for others to see.
I'll post again after that.
Thanks
If it's not broken, fix it until it is
|
|
|
|