|
Thanks for the reply Pete!
I will check that tomorrow if some class is named "LangExtension". I know there are two classes deriving the MarkupExtension class, so one of the must it be.
Another question: Is the MarkupExtension class meant to execute XAML code in design-time as well as runtime? The example I give with language project, in my original post, gives me a HUGE advantage when creating GUIs.
I have tried to understand the documentation of Markup extension on MSDN[^] but it is to big to scope, to generalized explaination and no obvious super easy example
Any suggestion of source which I can study?
/Steffe
|
|
|
|
|
Mc_Topaz wrote: Another question: Is the MarkupExtension class meant to execute XAML code in design-time as well as runtime? Well, that's the thing. Basically, in order to render a view of your UI in the designer, your code is periodically compiled and a new "snapshot" instance of the UI is rendered into place. This means that you get a version of a running app displayed, so it renders a design time view that just happens to have been created from a runtime version. So yes, your MarkupExtension will run.
Ooh, a simple MarkupExtension. Now, that's a thing. The good Dr WPF has some great examples here[^] that might shed some light for you.
However, a point for you to ponder - the use of {...} in XAML indicates that there's a MarkupExtension in there. So, whenever you see Binding, StaticResource, DynamicResource, etc, these are all markup extensions - indeed, if you were to look in the Object Browser, you would see they all have Extension after them - so it's BindingExtension, etc.
|
|
|
|
|
Pete O'Hanlon wrote: so it's BindingExtension, etc.
Actually, Binding is one of the ones that doesn't have the ...Extension suffix.
The *Extension naming pattern is for convenience and consistency. It is not necessary in order for a XAML processor to identify that class as support for a markup extension. So long as your codebase includes System.Xaml and uses .NET Framework XAML Services implementations, all that is necessary to be recognized as a XAML markup extension is to derive from MarkupExtension and to support a construction syntax.
WPF defines markup extension-enabling classes that do not follow the *Extension naming pattern, for example Binding . Typically the reason for this is that the class supports scenarios beyond pure markup extension support. In the case of Binding , that class supports run-time access to methods and properties of the object for scenarios that have nothing to do with XAML.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I guess I should read the documentation some time
|
|
|
|
|
I am implementing (soon on CodePlex) a.. MenuRibbon control (both menu and ribbon)
Anyway, I am now trying to implement the resizing behavior of a RibbonTab, and need some ideas...
I even downloaded the official open source version of the WPF Ribbon from MS[^], but it is very slow resizing (at least the open source version). Further the resizing code is somehow hard to follow, I found...
I identified that:
- A RibbonTab is an ItemsControl of RibbonGroup
- RibbonGroup have discrete sizes (i.e. large, medium, small for example) or... star size (which means it has a min, a max, and many value in between which are somehow difficult to determine (it's a property of its children possible value of visual tree, it happen when there is gallery in the RibbonGroup for example)). All RibbonGroup have a last smallest possible size of collapsed.
now I need an algorithm which choose a size combination for each control which choose a nice visual combination of these know (discrete) and unknown (star) sizes...
I am probably tired.. but I have blank page problem right now...
[EDIT] Time for bed! At any rate I think I know my biggest Hurdle, I need to put these size definition in C#, and while the StarSize is only one item in the possible size definition, it should contains a list of discrete value itself.
After that I'll be back to multiple list of size (i.e. discrete and finite) from which I just have to pick one value in each for most aesthetically pleasant result....
modified 8-Jul-14 10:33am.
|
|
|
|
|
Hi
I have a listview (gridview) and I want to show the items side by side if there are more than x items in the collection.
Something like this:
With few items
Item1
Item2
Item3
Item4
With more than x items
Item1 Item5 Item9
Item2 Item6 Item10
Item3 Item7 Item11
Item4 Item8 Item12
How can that be done in xaml?
|
|
|
|
|
If you know the height of your items, wrap them in a WrapPanel with the Orientation set to Vertical based on n * the height of the item.
|
|
|
|
|
Thanks and that did the trick
|
|
|
|
|
I have a custom Panel with custom controls which should resize like RibbonButton, i.e. as the available size vary I should remove / add a header, resize an inner picture, etc...
Further the custom controls are lookless control, i.e. UI/Template is defined in the style, and I use triggers to update template element.
I communicate size setting from the panel to the individual controls by using an inherited attached property (I mean UI inheritance, like DataContext)
When I do my multi pass MeasureOverride() in my panel, when I call child.Measure(), it's as if my items are always the same size!!
Despite me changing the inherited attached property (and it does update inside control!)
To be clear my inside control don't resize, but when I change the inherited property, they change their UI template (to a smaller version)
Any clue how I can successfully implement RibbonButon and RibbonGroupPanel like behavior?
EDIT I just fixed my sample!
To give you an idea here is the code for the shorter sample I could write:
Size123Panel & Size123Control
public class Size123Control : Control
{
static Size123Control()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(Size123Control), new FrameworkPropertyMetadata(typeof(Size123Control)));
}
}
public class Size123Panel : Panel
{
public static int GetSize123(DependencyObject obj) { return (int)obj.GetValue(Size123Property); }
public static void SetSize123(DependencyObject obj, int value) { obj.SetValue(Size123Property, value); }
public static readonly DependencyProperty Size123Property = DependencyProperty.RegisterAttached(
"Size123", typeof(int), typeof(Size123Panel),
new FrameworkPropertyMetadata(3,
FrameworkPropertyMetadataOptions.Inherits
| FrameworkPropertyMetadataOptions.AffectsMeasure
| FrameworkPropertyMetadataOptions.AffectsParentMeasure
| FrameworkPropertyMetadataOptions.AffectsArrange
| FrameworkPropertyMetadataOptions.AffectsParentArrange
));
protected override Size ArrangeOverride(Size finalSize)
{
double hTot = 0, h = 0, x = 0, xMax = 0;
foreach (UIElement child in Children)
{
var cs = child.DesiredSize;
if (x > 0 && x + cs.Width > finalSize.Width)
{
hTot += h;
x = 0;
h = cs.Height;
}
else
{
if (cs.Height > h)
h = cs.Height;
}
child.Arrange(new Rect(new Point(x, hTot), cs));
x += cs.Width;
if (x > xMax)
xMax = x;
}
return new Size(xMax, hTot + h);
}
protected override Size MeasureOverride(Size availableSize)
{
Func<Size> measure = () =>
{
double hTot = 0, h = 0, x = 0, xMax = 0;
foreach (UIElement child in Children)
{
child.Measure(availableSize);
var cs = child.DesiredSize;
if (x > 0 && x + cs.Width > availableSize.Width)
{
hTot += h;
x = 0;
h = cs.Height;
}
else
{
if (cs.Height > h)
h = cs.Height;
}
x += cs.Width;
if (x > xMax)
xMax = x;
}
return new Size(xMax, hTot + h);
};
SetSize123(this, 3);
var s1 = measure();
if (s1.Width <= availableSize.Width && s1.Height <= availableSize.Height)
return s1;
SetSize123(this, 2);
var s2 = measure();
if (s2.Width <= availableSize.Width && s2.Height <= availableSize.Height)
return s2;
SetSize123(this, 1);
var s3 = measure();
Console.WriteLine("Size123: {0}, {1}, {2}", s1, s2, s3);
return s3;
}
}
generic.xaml
<Style TargetType="{x:Type local:Size123Control}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:Size123Control}">
<Border x:Name="MAIN" Width="48" Height="48" Background="Red" BorderThickness="1" BorderBrush="LightGray"/>
<ControlTemplate.Triggers>
<Trigger Property="local:Size123Panel.Size123" Value="2">
<Setter TargetName="MAIN" Property="Background" Value="Green"/>
<Setter TargetName="MAIN" Property="Width" Value="32"/>
<Setter TargetName="MAIN" Property="Height" Value="32"/>
</Trigger>
<Trigger Property="local:Size123Panel.Size123" Value="1">
<Setter TargetName="MAIN" Property="Background" Value="Blue"/>
<Setter TargetName="MAIN" Property="Width" Value="16"/>
<Setter TargetName="MAIN" Property="Height" Value="16"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
And the test window:
<local:Size123Panel>
<local:Size123Control/>
<local:Size123Control/>
<local:Size123Control/>
<local:Size123Control/>
<local:Size123Control/>
<local:Size123Control/>
<local:Size123Control/>
<local:Size123Control/>
<local:Size123Control/>
<local:Size123Control/>
<local:Size123Control/>
<local:Size123Control/>
<local:Size123Control/>
</local:Size123Panel>
If you look the console, when there is not enough space and control are shrunk, all 3 computed size are the same!
modified 3-Jul-14 5:48am.
|
|
|
|
|
Hi ,
I am using the following code to form a cube. It uses triangles for each face. How can I make a rectangular box by modifying its values. I dont have much idea on the indices property used here.
<GeometryModel3D.Geometry>
<MeshGeometry3D
Positions = "-1,-1,1 1,-1,1 1,1,1 -1,1,1"
TriangleIndices = "0 1 2 2,3,0"
TextureCoordinates="0,1 1,1 1,0 0,0"
/>
</GeometryModel3D.Geometry>
Thanks and Regards
Subin
|
|
|
|
|
It is explained pretty well on MSDN in:3-D Graphics Overview[^]
The section on Model and Mesh Primitives explains how the Positions and TriangleIndices relate. (Although it says there are twelve groups of three indices in the example, only two are actually there...)
A positive attitude may not solve every problem, but it will annoy enough people to be worth the effort.
|
|
|
|
|
I have just started learning WPF and read about XAML. I want to know if XAML is used anywhere also apart from WPF ? Can it be used with Java or any other language ?
|
|
|
|
|
Member 9719359 wrote: I want to know if XAML is used anywhere also apart from WPF ? Silverlight. Windows Phone. Windows Store Apps. Xamarin uses a variant for their cross platform work with Android and iOS.
|
|
|
|
|
I have an Expander in a ListItem data template.
When the Expander is collapsed, it minimizes horizontally to left so it's collapsed with is small. How can I set it so that with doesn't changed when collapsed?
Thanks
If it's not broken, fix it until it is
|
|
|
|
|
What have you set your ExpandDirection to? Try setting it to Down .
|
|
|
|
|
Hi,
I am new to prism framework. So I created a Obervable collection for datagrid. So When i poulated it the view was also affected and it showed whatever the chnge was.
But when i use on a single variable the value is not chnaged in the view. So can you help me to sort out this issue
|
|
|
|
|
The only really remarkable thing about an ObservableCollection is that it implements INotifyCollectionChanged. This interface contains a CollectionChanged event when the number of items in the collection is changed somehow. When WPF sees that an item it is binding to implements this interface, it knows that it can listen to this event.
Okay, so that's the ObservableCollection. Why did I bring it up? Well, that's because the collection changing is taken care of for you by a custom collection. Property changes, on the other hand, aren't handled automatically for you. When you think about it, you can see why this is desirable. Would you really want WPF to be listening for changes on every property you've bound it to, even if those properties are straightforward primitives. Implementing automatic change binding on these would put a tremendous strain on your application because you would potentially be wiring up many items that you don't want to. So, how do you do property change notification? Well, in just the same way you have INotifyCollectionChanged, there's a property change interface that WPF understands called INotifyPropertyChanged. This interface has a PropertyChanged event that you raise to tell WPF that a particular item has changed (by passing the name of the item that changed, or an empty string if you want WPF to refresh all properties).
Now, if you've heard of MVVM, you're probably aware of a concept called a ViewModel. The ViewModel is intended to isolate the View from the Model. It's a common implementation pattern that has a BaseViewModel class that handles the INotifyPropertyChanged (often abbreviated to INPC). So, the base VM would look something like this:
public abstract class BaseViewModel : INotifyPropertyChanged
{
protected void NotifyOfChange(string property)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler == null) return;
handler(this, new PropertyChangedEventArgs(property));
}
public event PropertyChangedEventHandler PropertyChanged;
} So, your derived VM would possibly look something like this:
public class MyViewModel : BaseViewModel
{
private int _onlineCount;
public int OnlineCount
{
get { return _onlineCount; }
set
{
if (_onlineCount == value) return;
_onlnieCount = value;
NotifyOfChange("OnlineCount");
}
}
}
|
|
|
|
|
I ve given like this. Should I inherit the view model class in the xaml.cs file.
The rest above i ve written as such in my project. But still not changing
|
|
|
|
|
Member 10053752 wrote: I ve given like this. Should I inherit the view model class in the xaml.cs file No.
Without seeing any of your code, it's difficult to see what the issue is.
|
|
|
|
|
if u can give me your mail id i can share my project with you
|
|
|
|
|
I can mail my project t u .. but can u give me ur mail id I can share it
|
|
|
|
|
Hello everyone
In my WPF project I have created a UserControl (this is called Applic.xaml), and within this usercontrol I have placed a nested UserControl (this is called PasswordScreen.xaml). Here is the xaml design code of Applic.xaml usercontrol:
<UserControl xmlns:my2="clr-namespace:iPosCloud.com.iposcloud.uiC_.views"
x:Class="iPosCloud.com.iposcloud.main.Applic"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:my0="clr-namespace:iPosCloud.com.iposcloud.main"
xmlns:Intersoft="http://intersoft.clientui.com/schemas"
xmlns:my1="clr-namespace:Intersoft.Client.UI.Controls;assembly=Intersoft.Client.UI.Controls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="800" d:DesignWidth="1024" xmlns:my="http://schemas.microsoft.com/surface/2008">
<UserControl.Background>
<ImageBrush ImageSource="/iPosCloud;component/images/HoneyComb.png" Stretch="Fill" TileMode="Tile" Viewport="0,0,46,25" ViewportUnits="Absolute" />
</UserControl.Background>
<UserControl.Resources>
<DropShadowEffect x:Key="DropShadowEffect" ShadowDepth="0.1" Direction="360" BlurRadius="3" Opacity=".5" />
</UserControl.Resources>
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Name="MainGridApplic">
<Border BorderThickness="2" HorizontalAlignment="Left" Name="border1" VerticalAlignment="Stretch" Margin="4" BorderBrush="{x:Null}">
<Border.BitmapEffect>
<DropShadowBitmapEffect Color="Black" Direction="360" ShadowDepth="10" Opacity=".5" Softness="9" />
</Border.BitmapEffect>
<Intersoft:UXGridPanel Margin="2" Column="1" Row="1" ItemHeight="220" ItemWidth="1190" Name="UXGridPanelLeft">
<Image Name="image1" Source="/iPosCloud;component/images/Logo.png" Width="1000" HorizontalAlignment="Left" />
</Intersoft:UXGridPanel>
</Border>
<Grid Margin="2" HorizontalAlignment="Right">
<my2:PasswordScreen /> "HERE IS THE UserControl THAT I PLACED..."
</Grid>
</Grid>
</UserControl>
In PasswordScreen.xaml usercontrol there is a button (called Login). On the click event when clicked, I want to call another xmal file called SwitchboardView.xaml and display it within the (Applic.xaml usercontrol) but it is not firing nothing and the code behind this button is:
private void btnLogin_Click(object sender, RoutedEventArgs e)
{
SwitchboardView sbv = new SwitchboardView();
Applic ap = new Applic();
ap.MainGridApplic.Children.Add(sbv);
}
Could someone please help me solve this problem with the sample of code (what am I doing wrong...)
Kind regards
Lapeci
|
|
|
|
|
Hi friends,
In Silverlight Web Application, how to display/call an .aspx page in a Frame or any other control when click on a link button?
Please solve my problem ASAP.
Thanks,
Raviteja
|
|
|
|
|
give me introduction about silverlight
|
|
|
|
|
Well, a few years ago, this really great guy called David Silverlight ran community sites for.NET developers. One day, he was invited to spend some time with Bill Gates who said he wanted to name a product after him to thank him for his work in the online.NET community. Fortunately they chose to use his second name.
|
|
|
|
|