|
Yes in a tab is ok, but how can i do this?
|
|
|
|
|
You'd create these "applications" as plug-ins that your application would use. Have a look at the Managed Extensibility Framework to get some ideas.
|
|
|
|
|
Good People,
I have an object that will hold data and bind to some controls. Sometimes it will just need to exist as one object, other times it will need to exist in a collection. In your opinion, what strategy should/can I use:
1) implement INotifyPropertyChanged on the object, and when needed, place it in the observable collection.
2) simply implement the object normally - without INotifyPropertyChanged - and then place it in the observable collection which will update any properties
By the way, is it possible to use INotifyPropertyChanged and place such objects in an ObservableCollection?
Thank's so much for any help or information you can provide.
Blitz
|
|
|
|
|
Use strategy 1. The ObservableCollection tells you when the collection has changed not when a property of an object inside it has changed.
|
|
|
|
|
Awesome! Thanks Pete. Appreciate you sharing your insight.
|
|
|
|
|
No problem mate. Always glad to help.
|
|
|
|
|
I want to set the default styling in some controls and want to set all properties in generic.xaml.
I am looking at folowing link
http://www.codeproject.com/KB/silverlight/mediabutton.aspx[^]
but if change some property for example
<Setter property="Cursor" Value="Arrow" />
to
<Setter property="Cursor" Value="Hand" />
Its not getting reflected when I run the application.
No idea why? Does anybody have any idea? I have done a lot of brainstorming but not able to find........
Thanks in advance,
|
|
|
|
|
In the constructor for the control(s), try adding
DefaultStyleKey = typeof(MyCustomControlClass);
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I have done that also but not able to achieve to get the default value....
|
|
|
|
|
What does the style look like? Can you show the code?
It can't have a Name/Key and it needs to have the correct TargetType.
The Build Action property for the generic.xaml file should be set to resource.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
My CS file is like this:
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
namespace MyCustomControls
{
public class MyControl: ContentControl
{
public string Content1
{
get { return (string)GetValue(ContentProperty1); }
set { SetValue(ContentProperty1, value); }
}
public static readonly DependencyProperty ContentProperty1 =
DependencyProperty.RegisterAttached("Content", typeof(string), typeof(MyControl),
new PropertyMetadata("a"));
public MyControl()
{
this.DefaultStyleKey = typeof(MyControl);
}
}
}
Generic.xaml
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:MyCustomControls;assembly=MyCustomControls">
<Style TargetType="local:MyControl">
<Setter Property="VerticalAlignment" Value="Bottom"/>
<Setter Property="HorizontalAlignment" Value="Right"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="VerticalAlignment" Value="Bottom"/>
<Setter Property="Content" Value="The Code Project"/>
</ResourceDictionary>
and the xaml file of the user control where I want to use the above custom control
<UserControl x:Class="MyPortal.Controls.ctrlLogin"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="400" Height="140"
xmlns:local="clr-namespace:MyCustomControls;assembly=MyCustomControls">
<Grid x:Name="LayoutRoot" Width="400" Height="500" Background="Gray" HorizontalAlignment="Center">
<Grid.RowDefinitions>
<RowDefinition Height="20"/>
<RowDefinition Height="480"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="400" />
</Grid.ColumnDefinitions>
<local:MyControl Grid.Column="0" Grid.Row="0"/>
</Grid>
</UserControl>
None of the default property which is there in the generic.xaml file is reflected in the custom control.
If we put this property in the xaml file of user control itself then it works fine. But our requirement is to put the default value having styles or the content in generic.xaml
|
|
|
|
|
You didn't post a complete style example, so it's hard to guess what's wrong.
Here's an example that works for me:
<Style TargetType="local:MyControl">
<Setter Property="VerticalAlignment" Value="Bottom"/>
<Setter Property="HorizontalAlignment" Value="Right"/>
<Setter Property="VerticalAlignment" Value="Bottom"/>
<Setter Property="Foreground" Value="#FF0000FF"/>
<Setter Property="FontWeight" Value="Bold"/>
<Setter Property="FontStyle" Value="Italic"/>
<Setter Property="Cursor" Value="Hand"/>
<Setter Property="Content" Value="The Code Project"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="local:MyControl">
<TextBlock Text="{TemplateBinding Content}"
Cursor="{TemplateBinding Cursor}"
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
VerticalAlignment="{TemplateBinding VerticalAlignment}"
FontFamily="{TemplateBinding FontFamily}"
FontSize="{TemplateBinding FontSize}"
FontWeight="{TemplateBinding FontWeight}"
FontStyle="{TemplateBinding FontStyle}"
FontStretch="{TemplateBinding FontStretch}"
Foreground="{TemplateBinding Foreground}"
Margin="{TemplateBinding Padding}" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks for ur kind support. The problem is solved....
|
|
|
|
|
As a point of courtesy, you should include how you solved the problem for future readers.
|
|
|
|
|
Hi Derek,
I have solved this problem with the above code given by Mark...
|
|
|
|
|
I’ve just started to build the UI for a quite big WPF-application, and the skeleton of the program will be built with tabs to separate each section of the program. So my question is: what is a proper way to manage all the code inside the TabItem-tags? There will be a lot of UI-code inside the tags (and a lot of code behind as well) so I’m wondering if I can build the UI and the code behind for each TabItem in a separate file and then include the file inside the TabItems?
I’ve been thinking a lot about WPF-pages, but I don’t know how to load them inside a TabItem (I don't even know if it's possibel). But that’s just me thinking, what’s your opinions?
My main file will look something like this:
<StackPanel>
<TabControl TabStripPlacement="Top">
<TabItem Header="Tab1" IsSelected="True">
<!-- Include Tab1 info -->
</TabItem>
<TabItem Header="Tab2">
<!-- Include Tab2 info-->
</TabItem>
<TabItem Header="Tab3">
<!-- Include Tab3 info -->
</TabItem>
</TabControl>
</StackPanel>
Thanks!
// Fredrik
|
|
|
|
|
I'm not sure about pages, but UserControls should work. If you are going to have several tabs that all have significant logic, I would recommend doing that to make it easier to manage.
|
|
|
|
|
Can we use ASP.NET website inside the Silverlight application?
|
|
|
|
|
salon wrote: Can we use ASP.NET website inside the Silverlight application?
No. Why do you want to use ASP.NET website inside Silverlight?
|
|
|
|
|
What do you mean by "Can we use it?"
Are you asking if you can reference asp.net objects from a silverlight application?
Are you asking if you can display/run asp.net pages within a silverlight control?
Are you asking if Silverlight application can host an asp.net site?
|
|
|
|
|
I had had a similar question a little while ago. i wanted to write the majority of the application in Silverlight but then wanted the ability to display aspx pages in a browser control within the Silverlight app.
I stopped the project before I really needed it so I never got far towards figuring it out really but I am still interested...
|
|
|
|
|
Well... let's say a Silverlight app must live inside a web page (e.g. an ASP .net web project).
How to integrate both applications?
--> ASP .net using WCF services inheriting the ASP .net context (session).
--> using the bridge enabled that let Silverlight access properites and method in the javascript and the other way around (you can call from javascript a silverlight method).
HTH
Braulio
/// -------------------------
Braulio Díez
DBSchemaEditor.com
Free Silverlight based DB Schema Modeling Tool
/// -------------------------
|
|
|
|
|
I have been using the MVVM pattern extensively to build a UI (as in the great samples "WPF Apps With The Model-View-ViewModel Design Pattern"[^] and "Creating an Internationalized Wizard in WPF" [^]. This is a great technique for UI development, and I thank Josh Smith and Karl Shifflett for their postings and assistance in this area.
While I have now got most of this working really well, I have hit a problem that I can't figure out how to solve in xaml or with data binding. I have a ListBox which I can add items to, but as the number of items exceeds the size of the ListBox, the items added at the bottom scroll out of view... I want to have the ListBox automatically scroll to display the last item. Can anyone tell me how to do this in xaml?
I have reviewed several posts regarding use of the ScrollIntoView method, but I do not know how to access this from xaml (I think it may not be possible as its a method). As this is using the MVVM pattern, there is no way (that I am aware of) to access the ListBox instance from the code, to be able to call ScrollIntoView.
Another solution would be to scroll to item n in xaml, which would be fine because I could then data bind to n. However I also have not been able to find a way to control the scrolling in xaml.
I'm realy surprised there seems to be no easy way to do this in xaml.
Any help would be greatly appreciated.
Thanks,
Tim
|
|
|
|
|
|
Hey guys,
I'm creating a control in blend and I'm having some trouble understanding how I would accomplish a certain task.
The idea is I put a textblock on a form and then during runtime, this textblock's text must change based upon 4 different buttons that are pushed within the same control.
The problem is, I'm new to WPF and Blend - and I am unsure if this is possible.
The only alternative is I add a label in place of the textblock and change that text programatically(using visual studio code) - is this the preferred method or is there a way to bind the textblock.text to one of the selected buttons and have it change dynamically upon the selected button?
Thanks in advance,
Smithy.
|
|
|
|