后台更改border的imgsource
ImageBrush brush = btnImage.Background as ImageBrush;
长按按钮控件
RepeatButton
后台调用样式资源
控件.Style = FindResource("样式资源") as Style;
后台设置颜色
控件.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#F19958"));
使用listview或者listbox时,当一列的内容超出了宽度,则显示省略号,listview可以,listbox待试
需要外层套一个border才能生效,具体原因待研究
<Border Height="40">
<TextBlock Style="{StaticResource mListViewItemStyle_TextBlock}" HorizontalAlignment="Left" Name="txtProjectContect" VerticalAlignment="Center"
//重要代码
TextTrimming="CharacterEllipsis" ToolTip="{Binding RelativeSource={RelativeSource Self},Path=Text}"
Text="{Binding Path=name , Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
</Border>
改变图片抗齿距(添加到img控件中)
UseLayoutRounding="True" SnapsToDevicePixels="True" RenderOptions.BitmapScalingMode="HighQuality"
获取数据模板中的控件并可以修改的函数
///方法调用
EditableTextBlock tb = GetVisualChild<EditableTextBlock>(mCurrentTreeViewItem, v => v.Name == "lll");
///获取控件函数
public T GetVisualChild<T>(DependencyObject parent, Func<T, bool> predicate) where T : Visual
{
int numVisuals = VisualTreeHelper.GetChildrenCount(parent);
for (int i = 0; i < numVisuals; i++)
{
DependencyObject v = (DependencyObject)VisualTreeHelper.GetChild(parent, i);
T child = v as T;
if (child == null)
{
child = GetVisualChild<T>(v, predicate);
if (child != null)
{
return child;
}
}
else
{
if (predicate(child))
{
return child;
}
}
}
return null;
}