|
I have 3 collections of data that needs to be displayed in a treeview, so I'm trying to nest them. So far my XAML looks like this:
<UserControl.Resources>
<HierarchicalDataTemplate DataType="{x:Type models:ProductModel}"
ItemsSource="{Binding Categories}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding ProductNumber}"></TextBlock>
</StackPanel>
</HierarchicalDataTemplate>
<HierarchicalDataTemplate DataType="{x:Type models:CategoryModel}"
ItemsSource="{Binding Parts}">
<StackPanel Orientation="Horizontal"
Margin="0,3,0,3">
<TextBlock Text="{Binding Caption}"></TextBlock>
</StackPanel>
</HierarchicalDataTemplate>
<DataTemplate DataType="{x:Type models:PartModel}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding PartNumber}"></TextBlock>
<TextBlock Text="-"
Margin="3,0,3,0"/>
<TextBlock Text="{Binding PartDescription}"></TextBlock>
</StackPanel>
</DataTemplate>
</UserControl.Resources>
and then
<TreeView x:Name="tvwParent"
ScrollViewer.HorizontalScrollBarVisibility="Auto"
ScrollViewer.VerticalScrollBarVisibility="Auto"
BorderThickness="0"
Grid.Row="5"
Grid.Column="1"
Margin="5">
<TreeViewItem Header="Products">
<DataTemplate>
<TreeView x:Name="tvwSelections"
ScrollViewer.HorizontalScrollBarVisibility="Auto"
ScrollViewer.VerticalScrollBarVisibility="Auto"
BorderThickness="0"
ItemsSource="{Binding Products}"/>
</DataTemplate>
</TreeViewItem>
</TreeView>
When I run it I see the Products node, but it only has one child node showing as "System.Windows.DataTemplate".
I know the templates are correct, I just cant figure out why they are not being applied to the inner tree.
Anyone see what's wrong?
[MODIFIED]
I figured it out. I removed the DataTemplate and it works perfect.
Everything makes sense in someone's mind
|
|
|
|
|
Hi Guys..
I need to add scrollviewer in dragdockpanel. how to do this? plz help me...
|
|
|
|
|
If you want to scroll the elements of your panel, you can wrap it with a ScrollViewer .
If yow want to wrap an inner part of the control with a ScrollViewer , you can do it by changing the ControlTemplate of the control.
|
|
|
|
|
Hi,
How can I have a drag and drop listbox for rearranging items. Can someone give some pointers.
I want to mimic the way how the home screen arranges the items. i.e long tap on the item to select it for drag, then drop it into a new index.
I checked silverlight toolkit, but did not find anything.
- Thanks
|
|
|
|
|
I just find one. Is the dragdroptarget help ?
public abstract class DragDropTarget<TItemsControlType,TItemContainerType> : System.Windows.Controls.ContentControl
where TItemsControlType : System.Windows.UIElement
where TItemContainerType : System.Windows.UIElement
you can find it in the silverlight toolkit.
|
|
|
|
|
Thanks, Will check this and let you know.
|
|
|
|
|
This is not available in the Windows Phone version of the toolkit.
|
|
|
|
|
I have my model in the WCF, each model representing a table in the database (they are actually based on views to make them useful). Each field is an auto property with the basic get/set (no change event).
This model is propagated to the client via the reference of the WCF. So if I want to use the model I can reference it via Service.ModelName. This works perfectly and I am happily doing all my LOB work using this structure.
However this has a number of limitations that I can find. I have no model in the client and therefore cannot implement IEditable on the model. I also don't have and OnChange events on the model fields.
So far this is not painful but I feel I am doing it wrong. However the idea that I recreate the model in the client and extend it with the interface and event capability just feels wrong, getting the data from the WCF and moving it into and out of the local models just seems too clunky for my taste.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Personally, I implement INotifyProperty on my models, then reference the models in the client. Then I instruct my WCF service reference to reuse types in all referenced assemblies. So my tiers look something like this:-
public class Employee:INotifyProperty, IDataErrorInfo
{
}
public class EmployeeDataAccess
{
}
IEmployeeService
EmployeeService
public class EmployeeViewModel
{}
public class EmployeeView
{}
Of course the client is a little more complicated than shown as it has a service manager that actually deals with data I/O and acts as a mediator between viewmodels - but that's the gist of it - and it works .
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
Let me put that in words I understand!
Your model, originating in the WCF, has the full property declaration and the interface support.
There are no changes to your model (structure and additional interfaces etc) in the client.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
No the models are not in the WCF service, they are in their own library. The WCF service has a reference to the model library, and so does the client application. When you create your WCF service reference, you just ensure it reuses the referenced model library (obviously you need to reference the model library before you create the service reference). That way the service proxy is using the same models as the client app, it doesn't make it's own proxy models.
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
Wayne Gaylard wrote: you just ensure it reuses the referenced model library I knew there would be a catch, this sounds simple but I'll bet there is a bunch of nasty gotchas just waiting to jump out.
You don't by any chance know of a sample set up like this that can be studied do you? And yes I'm asking to snd t codz plz
It's Friday afternoon here so I'm off to a drinking hole, you have defined what I will be doing this weekend!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
It would only take me half an hour or so to set something up. Is it alright for me to email a VS 2010 solution to you. If so just drop me an email using the email tag below and let me know your address.
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
Thanks for the sample app - have a bunch of 5s in appreciation.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Thanks!
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
OtherClass.Subscribe<someclass>(_ => KeepWorking = !KeepWorking);
KeepWorking is a bool
This works fine, but what is Lambda expression _ =>
Best regards
Agha Khan
|
|
|
|
|
MSDN explains Lamda Expressions here[^].
|
|
|
|
|
Hi,
I'm facing a problem to bind a StoryBoard to a label in my WPF application.
My XAML lloks like this:
<Label Height="28" Margin="308,27,250,0" Name="PostingStatusLabel" VerticalAlignment="Top" HorizontalContentAlignment="Left" Foreground="ForestGreen" FontWeight="bold">
<ContentPresenter Content="Posting"></ContentPresenter>
<Label.Triggers>
<DataTrigger Binding="{Binding IsPendingPostExist}" Value="True">
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<StringAnimationUsingKeyFrames Storyboard.TargetName="PostingStatusLabel" Storyboard.TargetProperty="(Label.Content)"
RepeatBehavior="Forever" FillBehavior="HoldEnd">
<DiscreteStringKeyFrame Value="Posting" KeyTime="0:0:0.0" />
<DiscreteStringKeyFrame Value="Posting." KeyTime="0:0:0.25" />
<DiscreteStringKeyFrame Value="Posting.." KeyTime="0:0:0.5" />
<DiscreteStringKeyFrame Value="Posting..." KeyTime="0:0:1" />
<DiscreteStringKeyFrame Value="Posting...." KeyTime="0:0:1.25" />
<DiscreteStringKeyFrame Value="Posting....." KeyTime="0:0:1.5" />
<DiscreteStringKeyFrame Value="Posting......" KeyTime="0:0:1.75" />
</StringAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</DataTrigger.EnterActions>
</DataTrigger>
</Label.Triggers>
</Label>
When I'm trying to run this application.I get XAMLParseExeption at the start of Label.Triggers tag.
Anyone?
Best regards,
Eli
|
|
|
|
|
You're getting this exception because it's expecting an Event Trigger here, not a data trigger. If you want to use a DataTrigger, you have to apply it to a Style, ControlTemplate or DataTemplate. If I were you, I would create a style something like this:
<Style x:Key="LabelStyle1" TargetType="{x:Type Label}">
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Padding" Value="5"/>
<Setter Property="HorizontalContentAlignment" Value="Left"/>
<Setter Property="VerticalContentAlignment" Value="Top"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Label}">
<ControlTemplate.Resources>
<Storyboard x:Key="Storyboard1">
<ObjectAnimationUsingKeyFrames
Storyboard.TargetProperty="(ContentControl.Content)" Storyboard.TargetName="contentPresenter"
RepeatBehavior="Forever" FillBehavior="HoldEnd">
<DiscreteObjectKeyFrame KeyTime="0:0:0.3" Value="Posting."/>
<DiscreteObjectKeyFrame KeyTime="0:0:0.6" Value="Posting.."/>
<DiscreteObjectKeyFrame KeyTime="0:0:0.9" Value="Posting.."/>
<DiscreteObjectKeyFrame KeyTime="0:0:1.2" Value="Posting..."/>
<DiscreteObjectKeyFrame KeyTime="0:0:1.5" Value="Posting...."/>
<DiscreteObjectKeyFrame KeyTime="0:0:1.8" Value="Posting....."/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</ControlTemplate.Resources>
<Border BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}"
Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true">
<ContentPresenter x:Name="contentPresenter"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</Border>
<ControlTemplate.Triggers>
<DataTrigger Binding="{Binding IsPendingPostExist}" Value="True">
<DataTrigger.EnterActions>
<BeginStoryboard Storyboard="{StaticResource Storyboard1}"/>
</DataTrigger.EnterActions>
</DataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style> Then all you need to is define your label like this:
<Label
Content="Posting" HorizontalAlignment="Left"
VerticalAlignment="Top" Foreground="ForestGreen"
Style="{StaticResource LabelStyle1}"/>
|
|
|
|
|
Hi,
Thanks,it is working...
I have one more question:
I'm trying to stop the story board when the trigger is being changed from true to false.
I've set the story board name,and trying to stop it like this:
<Storyboard x:Key="Storyboard1" x:Name="Storyboard1">
.
.
.
<ControlTemplate.Triggers>
<DataTrigger Binding="{Binding IsPendingPostExist}" Value="True">
<DataTrigger.EnterActions>
<BeginStoryboard Storyboard="{StaticResource Storyboard1}"/>
</DataTrigger.EnterActions>
<DataTrigger.ExitActions>
<StopStoryboard BeginStoryboardName="Storyboard1"/>
</DataTrigger>
</ControlTemplate.Triggers>
but when the trigger switches to false,I receive the following InvalidOperationException:
"Storyboard1 object Name found but it is not a BeginStoryboard object."
Is there something I'm missing?
Thanks again,
Eli
|
|
|
|
|
The reason is, you haven't named the storyboard part you think you have. The key here is that it's BeginStoryboardName - which tells you that you need to apply a name to BeginStoryboard . Add a name to BeginStoryboard , and then use this name in the StopStoryboard .
|
|
|
|
|
Beginners faults...
Thanks a lot..
Best regards,
Eli
|
|
|
|
|
No problem. This is what we're here for - to help.
|
|
|
|
|
+5 for patience and persistence
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
Hi All,
I am using the WPF ribbon Library in my application for getting a ribbon control attached in my application.
I need the functionality where I can trap the minimize event in ribbon and do some additional stuff of code in there.
But, to my surprise I could not find any property named Minimized in ribbon .. I could found out collapsed and Expanded but they were of no use.
Can some body tell me what does IsMinimize property correspond to. As,if I know for which property the minimize functionality is attached,I can then easily solve my problem statement.
-Kushagra
I believe in Me !!!
|
|
|
|