Could you tell me which is the best MVVM pattern someone have to follow. where can i found hands on exmaple. Actually i was little confused which one to follow?
Thnx
All,
I have a user control, defined as follows.
<UserControl x:Class="IDOView.AnimatedCharacter"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:IDOView"
mc:Ignorable="d"
Background="Transparent"
>
<Image Name="displayImage" Height="Auto" Width="Auto" Stretch="Fill" IsHitTestVisible="True"/>
The control is added to a main page twice, as follows.
<local:customControl x:Name="A1" Height="259" Width="197" DisplayImage="circle.png" Canvas.Left="-279" Canvas.Top="-56" MouseLeftButtonUp="DoA1">
<local:customControl x:Name="A1" Height="259" Width="197" DisplayImage="square.png" Canvas.Left="-209" Canvas.Top="-56" MouseLeftButtonUp="DoA2">
Essentially, about half of the circle is behind the square.
I need the square image in this case to pass through events to the circle behind it. The square has an element cut out of it (transparent). What is happening now is that the circle event only registers if I click on the region that is not covered by the square. Surely there has to be a way to bubble this event, or click-through?
I need to draw a line with plusses along an given path (arch) but can't seem to find anything pointing me in the right direction.
Any help would me much appreciated.
Best,
Jon H
I have TextBlock in my main form. I set the Text property to different strings during the application run.
I would like to be able to colour parts of particular strings.
Say (pseudo-code)
if(a < 0) txbStatus.Text = string.Format("{0} <RED>{1}</RED>", a, b);
else txbStatus.Text = string.Format("{0} <BLUE>{1}</RED>", a, b);
I need to bind width property of the GridView column that is created dynamically in code.
Since GridViewColumn object has no SetBinding method, how should I do this?
Thanks in advance.
I have taken the MSDN templates for styling a scrollbar and have been trying to apply my different styles (Image on each track repeater and separate Image on the thumb) but I am unable to make the thumb change size.
I have tried setting the Width on the Track.Thumb style and also in the ControlTemplate of the Thumb itself. For some reason the default size is only ever rendered even when the thumb actually occupies much more space. Does anyone know how to make the thumb render at the size that I want?
The XAML I am using for the styles is here:
<Style x:Key="ScrollBarThumb" TargetType="{x:Type Thumb}">
<Setter Property="Background" Value="Red" />
<Setter Property="OverridesDefaultStyle" Value="True"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Thumb}">
<Image Source="sampleimg.png" Stretch="Fill" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<ControlTemplate x:Key="ArfleHBar" TargetType="{x:Type ScrollBar}">
<Grid >
<Grid.ColumnDefinitions>
<ColumnDefinition MaxWidth="18"/>
<ColumnDefinition Width="0.00001*"/>
<ColumnDefinition MaxWidth="18"/>
</Grid.ColumnDefinitions>
<RepeatButton Grid.Column="0" Style="{StaticResource ScrollBarLineButton}" Width="18" Command="ScrollBar.LineLeftCommand" Content="M 4 0 L 4 8 L 0 4 Z" />
<Track Name="PART_Track" Grid.Column="1" IsDirectionReversed="False" >
<Track.DecreaseRepeatButton>
<RepeatButton Style="{StaticResource ScrollBarPageButton}" Command="ScrollBar.PageLeftCommand" Width="100"/>
</Track.DecreaseRepeatButton>
<Track.Thumb>
<Thumb Style="{StaticResource ScrollBarThumb}" Margin="0,1,0,1" Width="250" Padding="0,0,0,0">
</Thumb>
</Track.Thumb>
<Track.IncreaseRepeatButton>
<RepeatButton Style="{StaticResource ScrollBarPageButton}" Command="ScrollBar.PageRightCommand" Width="100" />
</Track.IncreaseRepeatButton>
</Track>
<RepeatButton Grid.Column="3" Style="{StaticResource ScrollBarLineButton}" Width="18" Command="ScrollBar.LineRightCommand" Content="M 0 0 L 4 4 L 0 8 Z"/>
</Grid>
</ControlTemplate>
<Style x:Key="ArfleBar" TargetType="{x:Type ScrollBar}">
<Setter Property="SnapsToDevicePixels" Value="True"/>
<Setter Property="OverridesDefaultStyle" Value="true"/>
<Style.Triggers>
<Trigger Property="Orientation" Value="Horizontal">
<Setter Property="Width" Value="Auto"/>
<Setter Property="Height" Value="18" />
<Setter Property="Template" Value="{StaticResource ArfleHBar}" />
</Trigger>
</Style.Triggers>
</Style>
Hi,
I have the following defined in my control:
<local:TestListBox.ItemTemplate>
<DataTemplate>
<Border x:Name="eventBorder" Width="{Binding ElementName=eventsLbx, Path=ActualWidth,BorderBrush="{Binding Color}" BorderThickness="1" CornerRadius="4">
<Border.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop x:Name="StartGradient" Color="#FFFFFFFF" Offset="0"/>
<GradientStop x:Name="EndGradient" Color="{Binding Color}" Offset="1"/>
</LinearGradientBrush>
</Border.Background>
<Border.ToolTip>
<ToolTip Content="{Binding Text}"/>
</Border.ToolTip>
<TextBlock TextTrimming="CharacterEllipsis" HorizontalAlignment="Center" FontSize="12" Text="{Binding Text}" />
</Border>
<DataTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="eventBorder" Property="Background" Value="#FFE4EBF5"/>
</Trigger>
</DataTemplate.Triggers> -->
</DataTemplate>
</local:TestListBox.ItemTemplate>
</local:TestListBox>
</ScrollViewer.Content>
</ScrollViewer>
</Grid>
<ControlTemplate.Triggers>
<Trigger SourceName="eventsLbx" Property="HasItems" Value="False">
<Setter TargetName="eventsLbx" Property="Visibility" Value="Hidden"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
Now if there are more items than are visible, then the scrollviewer appears properly but the user CANNOT drag the scrollviewer middle button for scrolling.
The user can click on the arrows at the end of the scrollviewer to scroll but he cannot click the bar that appears on the scrollbar and drag it to actually scroll the contents.
I cannot figure out why this is happening...
So I have a string like Русское Имя how to represent it as real string with wcf textBox? And How to encode for example russian string inputed into textInput into UTF-8?
struct Drink
{
public string Name { get; private set; }
public int Popularity { get; private set; }
public Drink ( string name, int popularity )
: this ( )
{
this.Name = name;
this.Popularity = popularity;
}
}
List<Drink> coldDrinks = new List<Drink> ( ){
new Drink ( "Water", 1 ),
new Drink ( "Fanta", 2 ),
new Drink ( "Sprite", 3 ),
new Drink ( "Coke", 4 ),
new Drink ( "Milk", 5 ) };
}
}
So that I can see the Name property for treeview item names.
Hello!
I need to define a user control in runtime and then instantiate it wherever I want. So it should not be just a "new UserControl()" (that will be an instance of a UserControl class) but the one I can use as a template. Should I use reflection to generate new type or is there a better way?
Thanks!
Let's say we have a text field named TXTBLAH and a setting named SETTINGBLAH
Is there anyway to write in XAML markup that whenever the text field BLAH gets updated to write that to the registry, and also when the form loads is there a XAML binding to restore it?
I'm building a custom Silverlight UserControl which needs to listen to events using Preview/Tunneling, but for some reason the compiler is telling me they are not recognized or accessible.
For example, I can add an event handler to MouseLeftButtonDown, but not PreviewMouseLeftButtonDown. This doesn't make sense because according to Microsoft (http://msdn.microsoft.com/en-us/library/system.windows.uielement_members(v=VS.100).aspx) all UIElements should have Preview events attached.
Any ideas as to why this is happening? I'm using Visual Studio 2010 Trial, Blend 4 RC and .Net 4, if that makes a difference.
The following xaml looks fine in XP, but the bottom of the text gets cut off in Vista and Windows 7.
<Grid>
<Border Height="86"
Margin="10,54,10,0"
VerticalAlignment="Top"
BorderBrush="Black"
BorderThickness="1"/>
<Label Height="22"
Width="100"
Margin="15,43,0,0"
VerticalAlignment="Top"
HorizontalAlignment="Left"
Background="White">Text Over Border</Label>
</Grid>
I realize that I could just increase the Height of the label, but I'm guessing I'll have problems with systems that have different resolution settings, or large text settings. Is there a better way to lay this out?
TextChangedEventArgs is being fired twice in my RichTextBox control.
Is this normal?
Also, when will e.Changes (you know the TextChangedEventArgs) be 1. The only case I can think of is someone pasting content into it.
But other times it seems in normal typing a person can really only change 1 paragraph right?
Hi
There is a list box with some items in it. Also there is a grid with 3x3 matrix. The user will be dragging an item and dropping on one the cells of grid.
Most of the samples I found are about dragging-dropping from one listbox to another listbox. But I want to drop in one cell of grid. How can I achieve this?
Please advise. thanks
PJ
Hello,
I have several UserControls that have some of the same controls doing the same job.
Is it possible to extract those controls into a base class?
When I have tried it, I get an error that the definition in the generated .g.cs file will hide the parent def.
What I would like to do:
public class ctlBase : UserControl
{
internal CheckBox chkBox { get; set; }
}
In the .xaml of the derived class:
<Grid>
<CheckBox x:Name="chkBox" />
</Grid>
public class DerivedCtl : ctlBase
{ }
Thanks for any insights...
I want to position a modal dialog (progress window) at the top right corner of the parent window client area.
This code will put it in the corner of the non-client area, but how do I calculate the offset to the client area?
this.Owner=owner;
this.Left=owner.Left+owner.ActualWidth-Width;
this.Top=owner.Top;
Edit:
I found this 'solution' that works for normal windows:
this.Left=owner.Left+owner.ActualWidth-Width-SystemParameters.ResizeFrameVerticalBorderWidth;
this.Top=owner.Top+SystemParameters.ResizeFrameHorizontalBorderHeight+SystemParameters.WindowCaptionHeight;
This would however fail for windows that have customized borders.
EDIT:
The code should work regardless of the systems DPI setting (e.g. 120 instead of 96).
I'm building a special listbox control that our designers want customized in some tweaky ways.
One thing they want to see is that the middle button-drag does what the left button-drag normally does (we are repurposing left-drag to other things).
So it needs the two key features that left-drag does in a ListBox default implementation:
While holding down the button and dragging, the selection starts where I click down and extends to where I drag.
While dragging outside the listbox region, it scrolls if there is scrollable space in that direction.
Before I go an duplicate this functionality by hand, is there any easy way to fool ListBox into thinking it's getting left-mouse drag events but instead is getting middle-mouse?
I want an Expander that only expands/collapse it's content when the user clicks on the header icon. (Instead of the whole header being clickable.)
Do I have to redefine the control Template to do this? How would it look like?
Where can I find the standard templates/styles for controls?
Thanks for your time.
Can someone explain this XAML statement, particularly what is the Resolve?
<MenuItem Header="_Load File" Command="{Resolve {Type Commands:LoadFile}}" />
I'm building a simple hex editor in C#, and I've decided to use each cell in a DataGrid to display a byte*. I know that DataGrid will take a list and display each object in the list as a row, and each of that object's properties as columns. I want to display rows of 16 bytes each, which will require a wrapper with 16 string properties. While doable, it's not the most elegant solution. Is there an easier way? I've already tried creating a wrapper around a public string array of size 16, but that doesn't seem to work.
Thanks
*The rational for this is that I can have spaces between each byte without having to strip them all out when I want to save my edited file. Also it seems like it'll be easier to label the rows and columns.
In the program I am trying to build, I have a menu button that opens a second window. The user puts information into the second window, presses the "Done" button, and the information is transfered into the main window. The problem I am having is opening the second window. I have both windows build in xaml files in Visual Studio but I can't find a way to show the second window. Using "Window window = new Window" does not fit my needs because 1) I already have the second window built and 2) I have tried this and I cannot figure out how to add children to the window; there is no window.children nor any grid to put the children into. Thank you in advance!
In the model, I have:
public ObservableCollection<Item> Items { get; private set; }
In the ViewModel, I have a corresponding list of ItemViewModels:
public ObservableCollection<ItemViewModel> ItemViewModels ...
In the XAML, I will bind (in this case a TreeView) to the ItemViewModels property.
My question is, what goes in the "..." in the ViewModel shown above? I am hoping for a line or two of code to binds these two ObservableCollections (providing the type of the ViewModel to construct for each model object). However, what I'm fearing is necessary is a bunch of code to handle the Items.CollectionChanged event and manually updates the ItemViewModels list by constructing ViewModels as necessary.
Thanks!
Eric
I've run into a case where I have a custom Panel (inherits from Panel) and I'm using it as an ItemsPanel in a ListView.
When I resize the container that it's in, if I resize it smaller, my panel's MeasureOverride function gets called once, but if I resize it larger (let's say from 100 to 300), it calls MeasureOverride and ArrangeOverride for every value between 100 and 300, in increments of 2 (so 102, 104, etc.).
The weird thing is that the container resizes right away (its size gets to 300 immediately).
It doesn't seem to matter what I return from MeasureOverride - it just does this.
I wish I could make it happen in a really small application and post it here, but I haven't been able to reproduce it like that yet. I can reproduce it all day in my app though.
Does anyone know what could cause this?
I am binding a ListView a property that essentially wraps the Values collection (ICollection) on a generic dictionary.
When the values in the dictionary change, I call OnNotifyPropertyChanged(property). I don't see the updates on the screen, with no binding errors.
When I change the property getter to return the Linq extension dictionary.Values.ToList(), without changing the signature of the property (ICollection) it works with no problem.
Any reason why the Values collection bind and notify properly without projecting to an IList<?